Re: Re: Cocoa/Obj-C Restart Computer
Re: Re: Cocoa/Obj-C Restart Computer
- Subject: Re: Re: Cocoa/Obj-C Restart Computer
- From: Tim Hewett <email@hidden>
- Date: Fri, 30 Jul 2004 23:59:57 +0100
You can use the system() library call to call shell commands,
see "man 3 system".
Two problems with using "shutdown -r now":
1. you need to have an effective uid of root to use it.
2. you have to hope to hell that you don't have any unsaved
documents in your login session or anything else that apps might
need to do before quitting. Shutdown will just kill them without
asking any questions.
I'd investigate the other options which people have suggested
which use existing Apple "approved" mechanisms, for safety's
sake.
Tim.
On 30 Jul 2004, at 23:12, email@hidden wrote:
Hmmm, well the terminal command: "shutdown -r now" will do that. All
you need to do is call that from Objective-C. I don't remember how to
call terminal commands off the top of my head, but worst comes to worst
you can stick it in an applescript.
Try a "man shutdown" to see all the options and do a search on the
apple docs to see how to put a terminal command in a Cocoa app.
On Jul 30, 2004, at 5:41 PM, Matt Jaffa wrote:
Hi,
I was wondering if there was any command in Cocoa/Obj-C to restart the
computer, so that my app can do that when they push a button.
Or any other way of doing this would be fine.
Matt
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.