New topic: Restart mac programatically (not AppleScript) ?
<http://forums.realsoftware.com/viewtopic.php?t=46534> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message jay4365 Post subject: Restart mac programatically (not AppleScript) ?Posted: Sat Jan 12, 2013 6:14 am Joined: Tue Dec 18, 2012 7:29 am Posts: 5 Does anyone know a way to programatically restart a mac other than using Apple Script? I've been looking into Apple Events, the code below seems to 'send' ok but nothing happens: A = New AppleEvent("aevt", "rest", "com.apple.systemevents") If A.Send Then // Else MsgBox "Bah hum bug." End If .I tried variations: AppleEvent("aevt", "rest", "com.apple.finder") AppleEvent("FNDR", "rest", "com.apple.finder") AppleEvent("FNDR", "rest", "com.apple.systemevents") (using latest RB Pro, ML 10.8.2, iMac 2.66GHz 4 GB RAM, xCode and tools installed) Top Goofie Post subject: Re: Restart mac programatically (not AppleScript) ?Posted: Sat Jan 12, 2013 9:41 am Joined: Tue Nov 13, 2007 11:48 am Posts: 182 Location: Belgium If you don't want to use AppleScript, you have alternatives... (1) take a look at the Shell class to give the appropriate unix command... It should be easy to attach the following code to a button... Dim s As Shell s = New Shell s.Execute("the command i want to execute") For the right command look at developer.apple.com e.g. http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/shutdown.8.html (2) You can also explore the launchd-daemon, in combination with Lingon http://www.peterborgapps.com/lingon/, then you even don't need to use RealBasic Top ktekinay Post subject: Re: Restart mac programatically (not AppleScript) ?Posted: Sat Jan 12, 2013 1:25 pm Joined: Mon Feb 05, 2007 5:21 pm Posts: 354 Location: New York, NY This will work too: dim sh as new Shell sh.Execute "osascript -e 'tell app ""System Events"" to restart'" Or you can create a standalone AppleScript with that command and include it in your project. _________________ Kem Tekinay MacTechnologies Consulting http://www.mactechnologies.com/ Need to develop, test, and refine regular expressions? Try RegExRX. Top jay4365 Post subject: Re: Restart mac programatically (not AppleScript) ?Posted: Mon Jan 14, 2013 11:24 am Joined: Tue Dec 18, 2012 7:29 am Posts: 5 Thanks both of you, I'll use the shell method for now. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
