VBScript shutting down before prompt, suggestions?

 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.
linkShutdown.Save


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 

Script!")

If answer = 1 then
Initiate_Logoff()
End if

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

End Function

May 29th, 2015 2:18am

No idea what you are asking.  A shortcut does not have code. It points to a program or script.
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2015 2:36am

Your code can never run.  It has too many syntax errors.  Fix the errors first.\

Why is there an "End Function" in the middle of the code.

If you earned too format code properly you would see where your errors are very quickly.

May 29th, 2015 2:40am

Fixed.
Free Windows Admin Tool Kit Click here and download it now
May 29th, 2015 3:03am

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

Other recent topics Other recent topics