I need help with my code. I am trying to make a script that does 2 things: First, it creates shortcut icon on the users desktop. Second, when the user double clicks the icon a box appears asking if they want to restart their computer giving them the option to click OK to restart to CANCEL to cancel the command. When entering the script into the command prompt it just executes the restart computer option. Any help would be greatly appreciated. Here is my script:
Dim answer
' ********* Main processing section **********
' Verify that the user wants to open the Turn Off Computer dialog
Set wshObject = WScript.CreateObject("WScript.Shell")
desktopFolder = wshObject.SpecialFolders("Desktop")
Set myShortcut = wshObject.CreateShortcut(desktopFolder & "\\Shortcut.lnk")
myShortcut.TargetPath = "%windir%\Shortcut.exe"
myShortcut.Save()
answer = MsgBox("The Turn Off Computer dialog will be opened.", 1, "Turn off Computer Script!")
If answer = 1 then ' User clicked on OK
Initiate_Logoff()
End if
' *********** Procedures go here *************
' Open the Windows Turn Off Computer dialog
Function Initiate_Logoff()
shellApp.ShutdownWindows
End Function
How about this: