Applescript startup at login
Ok. I want my script to add itself to login items when its run for the 1st time without having to do it manually, as in going to system preferences and accounts and so on. If you can help me please explain your code. Thanks.
simple enought in applescript:
set myPath to path to me
tell application "System Events"
make new login item at end of login items with properties {name:"your app name", path:myPath, hidden:false}
end tell
However, if you add your app to login items without asking permission from the user first, you will provoke irrational anger. put a display alert command before it to make sure people actually want this to happen.
Similar Messages
-
How to select the desired language in the item Startup and Login Windows?
Users can individually select the language in which applications are displayed by moving the entries in the Language list of the International pane in System Preferences into the desired order. However, this language preference only affects applications started by each user, it does not apply to the startup phase of the operating system and its login window. Under normal circumstances, this kind of language preference can only be set when installing or reinstalling the operating system.
How to modify this language preference without having to reinstall the system. Select the desired language in the item Startup and Login Language ?The language used by the login window is written in /Library/Preferences/.GlobalPreferences.plist. The file name begins with a dot . , so it is hidden in the Finder.
If it is OK for you to use unix command line, then you can modify this plist file by using "defaults" command as follows (CAUTION! please be careful no to make any mistakes, and do it at your own risk).
Open /Applications/Utilities/Terminal.app. and type
cd /Library/Preferences
cp .GlobalPreferences.plist saved-GlobalPreferences.plist
to make a backup copy of the plist. (if you get permission error, then try
sudo cp .GlobalPreferences.plist saved-GlobalPreferences.plist
and enter the admin password.)
Then type
defaults read /Library/Preferences/.GlobalPreferences AppleLanguages
to show the current setting. You can rearrange the list of languages as you like, for example,
defaults write /Library/Preferences/.GlobalPreferences AppleLanguages '(fr en)'
(or sudo defaults write .... if you get permission error)
I think you may make the list as short as you like.
If you don't like to use Terminal.app, then install Xcode (you can find it in Tiger install DVD, or download the latest version from Apple -- you need to register at Apple website to download it). It will install /Developer/Applications/Utilities/Property List Editor.app. You can edit /Library/Preferences/.GlobalPreferences.plist by this app by typing the following into Terminal.app (it's hidden in Finder so you must use Terminal.app to start editing it by Property List Editor):
open /Library/Preferences/.GlobalPreferences.plist
PowerMacG4, PowerBookG4, iMac(C2D) Mac OS X (10.4.8) -
I have a slow startup or login, with numerious spinning wheels. Sometimes after a long ti,e I can sign into the computer and sometimes it just fails to startup or login. I have a MacBookPro OS X 10.7.5 from 2011. It became more serious recently as I think I might have let my battery run out I also tried to download the operating system to reinstall it but it allways stops around 1.4 GB out of 1.7 then the whell starts again.
Keep the MBP attached to the power adapter.
First try SMC and PRAM resets:
http://support.apple.com/kb/ht3964
http://support.apple.com/kb/ht1379
Then try to boot the MBP in recovery (OPTION key down) and select the recover partition. Select Disk Utility>First Aid and verify and repair the HDD.
Additional steps can be found here:
https://discussions.apple.com/docs/DOC-3353
Ciao. -
Friend has a laptop running OSX 10.6.8, with latest software update 22Jun2012. One of the User's items to startup on Login is a file titled "
apple-scc-20111227-074257"
No idea what this does or where it is located.....any ideas on what it starts up and if it can be safely removed from startup items? Thanks for any info.If you mouse over the item in your Login Items you should see a tool tip indicating where it is. Alternatively right (control) click on it and a contextual menu item, Reveal in Finder will be shown which you can select to open the folder containing the item.
By the way the 20111227 portion of that name looks like a date -- 12/27/2011.
I'm sure you can delete it. Nothing major is going to happen. But you really should find out where it is.
If Reveal in Finder doesn't show anything it may be because the file is invisible (which might be considered somewhat suspicious). In that case use the finder find command (command-f) and look for kind filename plus invisible. Or just use Find any File to find it. -
My MacBook Air wont startup after login
my MacBook Air wont startup after login???
Try to boot your computer in Safe Mode: restart and hold the shift key down.
This can take some time, so be patient.
Explanation here: http://support.apple.com/kb/ht1564
If thyis leads to the computer booting, you can restart without holding the shift key down. -
Applescript "deamon" on system startup or login item
Hello:
I wrote an AppleScript script and saved it as an Applet that needs to run in the background whenever the system is up.
1/ I tried to set it as a startup item, so that it would start running as soon as the Mac is on -- however without success. I did not find out what the proper way is of doing this.
2/ Then I tried to set it as a login item for each user. This is not as good, but I thought it may an alternative, 'buying me some time' to figure out how to do it properly as a system startup item. Launching the app works fine, but the user cannot log off again, because the system cannot seem to quit the script. So I have to stop the process in Activity Monitor, obviously not a solution.
3/ Also, I would prefer the script to not show up in the Dock.
Any help is appreciated, especially on question #1.
Thanks,
HALHello twtwtw:
Thank you for your excellent advice and sorry for my ridiculous late reply.
Your first suggestion works smoothly, adding the "Application is agent" key to the Info.plist file via Xcode hides the app.
Also, I created the launchd launchagent plist file as you suggested and put it into /Library/LaunchAgents. The file name is irrelevant, I presume. The app itself is now in a subdirectory of /Library/StartupItems, which I thought is the appropriate place.
However, the app does not start, when a user logs in, instead I do have a permission problem with the following entry in Console:
Apr 29 19:08:31 My-Conputer com.apple.launchd.peruser.501[114] (...[277]): posix_spawn("/Library/StartupItems/SlowFan/SlowFan.app", ...): Permission denied
Apr 29 19:08:31 My-Computer com.apple.launchd.peruser.501[114] (...[277]): Exited with code: 1
So I have 4 questions:
1/ I do not understand why I am getting the permission error, because "System" has read & write access to the folder as well as on the application. What am I missing? My own user also has the same read & write permission, so if I start it myself, it works fine.
2/ Just out of curiosity, do you know what is the difference between the files in "/Library/LaunchAgents" and "/Library/LaunchDaemons"?
3/ In addition, what I really wanted was to launch the app, when the system starts, even if no user is logged in. Is this possible?
4/ If not, how do I avoid that the app runs multiple times in each user context? I want it to run once only.
As usual, any hint is appreciated!
Thanks,
HAL -
Running shell script at startup (before login)
Objective: on the Mac side of a dual-boot Intel, I want to automate running a shell script at startup that will unmount the "Untitled" Windows partition. As a single line command, the following runs correctly when invoked manually from Terminal:
/usr/sbin/diskutil unmount force disk0s3
How can I include this script in the startup sequence?V.K. asks: "why do you need to do this before login?" And macwiz1220 suggests including in Login Items an app created by AppleScript that launches Terminal and runs the diskutil command.
When I create and run such an app at login, I encounter problems with Terminal, which is why I thought to run an .sh script at startup. But if we can debug the problems with Terminal, then I won't have to venture into the more complex solutions offered by gbullman and Barney-15E. Terminal problems:
(1) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Close the window.
(b) Prompt before closing: Never
then the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
(2) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Close the window if the shell exited cleanly
(b) Prompt before closing: Never
then again the result is: Terminal is launched and exits quickly, but the "Untitled" volume is not unmounted.
(3) When Terminal prefs for Settings>Shell are set this way:
(a) When the shell exits: Don't close the window
(b) Prompt before closing: Always
then after invoking the script, Terminal properly unmounts "Untitled" and presents a dialog: "You have 2 windows with running processes. Do you want to review these windows before quitting?" Here are the two Terminal windows:
an echo of the cmd "/usr/sbin/diskutil unmount force disk0s3" followed by a report on return: "Volume on disk0s3 force unmounted." I don't want the user to have to see this and close the window.
(ii) a fresh Terminal session, no commands entered. I also don't want the user to have to deal with this.
How can I get Terminal to properly unmount the object, and shut down without demanding user interaction?
P.S. what is an O.P.? -
Screen Goes Black During Startup (after login)
Hello,
I have a 2005 Mac Mini PPC OS 10.4.11. This is the first problem I've had since purchasing the computer. This problem popped up out of nowhere. The screen goes black during startup just after I login into my account. I can hear the hard drive spin like it is finishing the startup process. The monitor power button blinks green.
I'm using the digital video cable. I tried switching to the VGA cable but the screen then goes black before the login screen.
The computer will startup in Safe mode.
I've tried Disk Utility (repair disk and repair permissions), Techtool Pro, Drive Genius, ColorSync Utility, Reset Pram, installed latest OS updates, and even re-installed the System twice (once because I removed all the Extension files and then the computer would not startup at all).
I've also tried removing cache files, plist files, startup files, preference files, and some or all of extension files.
The only applications I have recently installed were QuickTime Pro and a .flv movie player; both about a week before this problem started. I tried to uninstall them but could not figure out how.
What is the problem? How can this be fixed?
Thanks.
RichardHowdy. I have Had the same problem as you in regards to a ViewSonic Monitor and the Mac Mini. This is my post:
Monitor failure when switching resolutions
Using Displays with the Mac mini, Apr 1, 2008, Replies: 2
Running 10.5.2 on Mac Mini G4 1.42 Ghz with ATI Radeon 9200, 32 MB VRAM and ViewSonic VX922
When switching resolutions from 1280x1024 to 800x600 or vice versa, the monitor will cut to black and the power light on the monitor switches from solid green to flashing green. Only by combinations of powering down the mini and starting it up again with the monitor on or off will bring the monitor back to life. This problem makes it difficult to play World of Warcraft amongst other games. Any feedback in regards to this problem would be appreciated.
Thank You!
At this point, I am unable to switch Monitor resolutions. If I do, the monitor goes black, and I have to power everything down and wait a while before I can restart.
I've resigned myself to not switching resolutions, but I'm wondering if you've had any luck.
Thanks for your time!
Kevin -
Problems finishing startup after login
Hi everyone,
Looking for some advice in getting my dad's MacBook functioning properly. There's something wrong with... something. I've attached a thorough log, complete with everything from Console, detailing our endeavors over the course of a few hours. Here's the skinny:
- A few days ago, dad's MacBook spontaneously started hanging (or so it appeared) after successfully logging into his main account
- The screen saver will load if left alone; otherwise, nothing seems to be going on
- He and I talked over the phone; it SOUNDED like a bad hard drive, but I couldn't see what was going on. I advised he go buy a new internal drive (SSD--they're nice and wicked fast) and a backup drive and try to reclaim what he could
- A tech at MacAuthority in his town, after looking at the computer, deduced it was NOT a hard drive failure, but more likely a corruption somewhere in the startup process after the login
- He can start up in his main account if he boots in Safe Boot
- He created a "test" account, which starts up fine in regular boot
Today I decided to "lay hands" on the machine and see what was really going on. After multiple boots in regular and safe boot, examining Console results, and taking actions against issues that SEEMED to be likely culprits, I'm at a loss. Any ideas what could be going on?
https://www.dropbox.com/s/w8nqrzsk49vpewi/Login%20Troubles.rtf?dl=0Seriously? No one out there with a clue what might be going on here?
-
How do I get all users to show on screen upon startup for login?
New MacBook Pro with latest IOS. Yosemite10.10
I got my first MacBook Pro out of the box from the Apple store yesterday...Logged in as an initial admin user...Then I migrated my MacBook Air to it. All three imported users showed. Success!! Then I restarted the MacBook Pro and the startup screen shows only a single login option: The initial admin user login Icon and name that I used on the MacBook Pro just before migrating the other users in from my MacBook Air.
So, I deleted the initial user (I did not need it), so that the other users (already with admin rights) would be the only logical logins that should show upon restart.
Result: The initial "deleted" user shows still, all alone and none of the other users. So I now log in to this "deleted" user, it is very slow to start before the other logins eventually appear after the this delay.
How do I get my users to show at the login screen upon startup and restart?Go to Settings > General > Date & Time. Make sure your time zone is correct and turn on Set Automatically if it isn't on already.
-
Hi all,
I'm running Windows SBS 2011. I need to run a script at server startup, prior to login to any user account (like a service does...). This short script will check the status of another service. Because this
service depends on Exchange & SQL, it sometimes fails to start at reboot if Exchange and or SQL Server haven't finished initializing.
I was also thinking of using sc.exe to change the config of the service in question (adding dependencies), but this is a third-party software from Reuters, and I am somewhat reluctant to edit the configuration of someone else's code (and possibly break something).
This is a production server at a law firm.
here's the script:
start of listing
=============================================
@echo off
rem Look for ProLaw Groupware Agent in running Services.
rem check to see if ProLaw Groupware Agent is running. If it IS
rem running, jump to exit-program label, else run the Agent after
rem waiting for Microsoft Exchange & Microsoft SQL Server to start.
rem =======================================
:start
C:\Windows\system32\sc query "ProLawGroupwareAgent" | find "RUNNING" >> c:\temp\plgwagentstatus.txt
if errorlevel 0 goto :end
rem wait 10 min after server startup,
rem to (Allow Exchange & SQL to start)
rem THEN, start ProLawGroupwareAgent
rem ========================
echo "Service not started.... Let's wait 10 minutes, and retry." >> c:\temp\plgwagentstatus.txt
c:\
timeout /t 600 > nul
cd "\Program Files (x86)\ThomsonElite\ProLaw GroupwareAgent"
net start AgentHostService.exe
timeout /t 20 > nul
goto :start
:end
=============================================
end of listingWhat I do in this case (I don't have access to exact script I use) is a similar script scheduled via windows task scheduler every five minutes to check if service running, if not start it but you can have the IF-THEN-ELSE do whatever is required.
http://gallery.technet.microsoft.com/scriptcenter/01fcf945-ad73-44e0-8cb5-152432bc6bcf
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows]
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights. -
Removing items from startup/ at login
I let my nephew use my mac for a bit and after that it started up with loading virex scan and i movie can get it of form startup menu in utilities, system, or individual prefrence panes. HELP ME I have Fallen and can't re configure.
"can get it of form startup menu in utilities, system, or individual prefrence panes."
I don't really don't understand what that means, but if you want to remove something from your login items, remove it from the list found in:
System Prefernces --> Accounts --> Login Items -
I have 2 Lacie drives.
120 gig from 2003 and a 250 gig from this year.
Both have systems and can act as startup drives.
The older one always makes me "log in".
The newer drive does not.
In addition: {when just being used as extra drives by my emac}
the older drive comes out of sleep with a "improperly put away" flag, unmounts and remouts.
The newer dive never gives this message. It just comes back to life.
LaCie's Firmware swears both dirves have the "latest"
The old drive has had the old systems archived and trashed.
Any clues as to why I have to "Login" on the '03 and not the '06?
TIA
-wbajr
{all running 10.4.6}
eMac DVD Mac OS X (10.4.6)Hi Wesley,
I'll take a guess here:
The 03 system is not set to automatically log in on startup and asks for a login. It may also be disabled in the Security System Prefs.
And when it goes to sleep it's logging out after "xx" minutes of inactivity and disconnects all drives.
I don't have any LaCie drives, so I'm guessing here. -
Blank screen on startup before login
Hi, after the recent Yosemite update (10.10.3), my mac on startup, gives me the startup chime but stays in a blank screen for about 10 to 15 seconds before the apple logo shows up, followed by the login screen. This happens irrespective of whether the laptop is connected to a power adapter or not. I tried doing a safe boot and also a Disk Utility check but the problem persists. A friend of mine updated his mac a few days back and reporting the same problem to me. Any help would be appreciated. Thank you.
Exactly what is it that find to be the problem?
Open Startup Disk preferences. Select your startup volume then click on the Restart button. Then do the following:
Repair the Hard Drive and Permissions - Yosemite, Mavericks, Mountain Lion or Lion
Boot to the Recovery HD:
Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
Repair
When the recovery menu appears select Disk Utility and press the Continue button. After Disk Utility loads select the Macintosh HD entry from the the left side list. Click on the First Aid tab, then click on the Repair Disk button. If Disk Utility reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit Disk Utility and return to the main menu. Select Restart from the Apple menu.
If that does not help then you might try:
Resetting your Mac's PRAM and NVRAM
Intel-based Macs: Resetting the System Management Controller (SMC) -
How to mount one of two external drives on startup without login
I have a Mac Mini that runs as a server on my network. It has two external USB drives attached: one contains documents, and the other is a TimeMachine backup of the server. Neither disk mounts on a machine on the network until a user interactively logs in, but I would like one of them to be mounted at startup of a MacBook Pro on the network running OS X Mavericks 10.9.3.
The following script was suggested at <https://discussions.apple.com/message/5770284#5770284> in response to a desire to mount all external FireWire drives running under OS X 10.5 Leopard:
You can do this with the following command (note: it will ask for your admin password):
sudo cat >/Library/Preferences/SystemConfiguration/autodiskmount.plist <<"EOF"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AutomountDisksWithoutUserLogin</key><true/>
</dict>
</plist>
EOF
I have two questions about this command:
1. Is it valid for OS X Mavericks 10.9.3?
2. Can it be modified to mount only one of the external disks attached to the server (the one containing documents)?
Thanks in advance for your kind assistance with these questions.
Best wishes,
Stuart
Stuart A. Forsyth
<Email Edited by Host>I can now confirm this file
/Library/Preferences/SystemConfiguration/autodiskmount.plist
does automatically get created on Mavericks Servers but not on non-Server Mavericks machines. It is possible to create it on non-Server Mavericks machines and reports are this works as expected.
Obviously the fact it is created automatically by Server.app on Mavericks servers means Mavericks still supports this.
Rather than hand-editing the file as per the original tip the following will achieve the same goal but will result in a binary format plist file which is what Server.app would create.
sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool true
Maybe you are looking for
-
I am having a problem with the BBC iPlayer playing in a separate pop-out player. Their support people have asked me to check that javascript running is enabled. In the Preferences content tab there is no button to enable Javascript, in fact the Prefe
-
Core i7-2720QM on Macbook pro 2011: Turbo Boost doesn't work! It's possible?
I test my core speed with MacCPUID that show real time cpu frequency. I try it in normal condition and running extreme application. Everytime my cpu frequency is something like 2.199 - 2.200 but never more than 2.200 ghz. So I have to think that Turb
-
How to add convert traditional chinese / simplied chinese button?
After installing Microsoft Office 2010 Proofing Tools Kit Service Pack 1 (SP1), the button of Traditional Chinese to Simplied Chinese or vice versa still cannot be seen in the "Review" of Word. How can I install it?
-
I've never rendered in adobe before. I am going to play the video on a large projector, and want the best quality that will hold up on a Windows 7 laptop. I want to render at least 3 or 4 because if one doesn't work,then I'll have a back up, so pleas
-
Why can't I buy songs from Blutengel in Belgium?
Some weeks ago, I could buy songs from them and now not anymore? What's going on in Belgium? Grtz, Zamba