What are the best practices for forcing the system to reboot after quitting an application? I am creating a customized installer for a client that requires a reboot at the end. The installer has a GUI and uses an authenticated shell script (sudo password has previously been entered) to do most of the heavy lifting.
Thanks in advance for any thoughts. Sorry if this topic has been previously discussed. I haven’t managed to find a search term that pulls me up results I am looking for from the forum.
In one app I’m using the restart method below, to restart the App.
As I want to handle a restarted app differently, I pass the string “imRESTART” as args. Then in app.Open I test for args like this:
If Instr(System.CommandLine,"imRESTART")>0 Then
My restart method:
[code]Sub restart()
Dim n As Integer
n = MsgBox(app.kAppName + " will restart now.", 0)
If n = 1 Then //user pressed OK
#If TargetCocoa
Dim s As New Shell
Dim p2 As String = App.ExecutableFile.Parent.Parent.Parent.ShellPath.ReplaceAll("\","")
Dim cmd As String = "open -n '" + p2 + "' --args imRESTART"
// Now Restart the app
s.Execute(cmd)
App.imQuit // Cleanup and then Quit
#EndIf
#If TargetWin32 OR TargetLinux
App.ExecutableFile.Launch
App.imQuit
#EndIf
Elseif n = 7 Then
//user pressed No
End If
End Sub
[/code]
David, thanks. Sorry to be so long in getting back to you. I was away on vacation for a few weeks, but managed to get off a working solution to the client before leaving using your osascript approach. Appreciate it!