Vbscript help

Spec

Fully Optimized
Messages
1,641
okay...well im trying to create a script that when executed it brings up a window that asks if you want to shutodwn the computer, i already have the message box..but i am not sure how to exec shutdown.exe or w/e...so someone help me pleaessee
 
Well, The code for a shutdown, which would initiate in 30 second's would be:

shutdown -s -t 30. So the code from an imidate shudown would probs be:

shutdown -s -t 00


Enjoy.
 
x = MsgBox("System will be shut down immediately", ,"Immediate Shutdown")
shutdown -s -t 00

So..is that the code..? kuz when i run it it says there is an error on the last two charecters and it wont exec.
Edit: or would you put that in launch options if you can do that..im confused.
 
can't do a cmd line directly in vb like that, it doesn't know what to do with it. You would be to have a batch file and have the cmd line:
Code:
shutdown -s -t 00

then in your vbscript file, something along the lines of:
Code:
Dim x
Dim WSHShell
x = MsgBox("System will be shut down immediately", ,"Immediate Shutdown")
if (x = vbYes) then
  Set WSHShell = CreateObject("Wscript.Shell")
  WSHShell.Run ("c:\yourBatfile.bat") 
end if

in the line WSHShell.Run, you may be able to put "shutdown -s -t 00" into the quotes and run it without the batch file.
Code:
WSHShell.Run("shutdown -s -t 00")

hopefully that helps ya out a bit,

Adam
 
Okay..well i've tryed with the batch file and without with this

WSHShell.Run("shutdown -s -t 00")

Still not working..wont shut computer off.

EDIT: Nvm guys, it works...i noticed that it

if (x = vbYes) then

I only had an OK button.

Thanks.
 
Back
Top Bottom