New to Scripting, Need help with VBScript shutting down before prompt.

Ok so here it is, I need to create a shortcut in which I can be prompted if I would like to shut down windows (Action to shutdown when clicking ok). Any ideas?

So far the working shutdown shortcut that I have does not issue the prompt a message asking if I truly want to shutdown or cancel the shortcut request.

Helpful suggestions are very much needed, as I mentioned I am new to scripting.

It does not work, won't help what I already know ;)

Here it is:

Dim shellApp, answer

REM Creates Shortcut with a Path to the desktop.
Set Shell = CreateObject("WScript.Shell")
  DesktopPath = Shell.SpecialFolders("Desktop")

REM Establishes and names the shortcut Shutdown.
Set linkShutdown = Shell.CreateShortcut(DesktopPath & "\Shutdown.lnk")
REM Adds shutdown code to the shortcut.
linkShutdown.Arguments = "-s -t 01"

REM Adds Description to shortcut that displays message on link over.
linkShutdown.Description = "Shutdown this Computer"
REM Creates Icon for shortcut using system shutdown icon.
linkShutdown.IconLocation = ("%SystemRoot%\system32\SHELL32.dll,27") 
REM Retrieves shutdown target path for shortcut.
linkShutdown.TargetPath = "shutdown"

REM Saves the Script.

REM Prompts the user if they want to shutdown their computer, 
REM displays ok and cancel buttons for the user to choose.
Set shellApp = CreateObject("Shell.Application")
answer = MsgBox("Do you really want to shut down the computer?", 1,"Turn off Computer 


If answer = 1 then
End if

REM Function that shuts computer down.
Function Initiate_Logoff()
REM Adds shutdown code to the shortcut.

End Function

May 29th, 2015 3:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics