Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 10-01-2007, 02:41 PM   #1
Fully Optimized
 
Spec's Avatar
 
Join Date: Aug 2005
Posts: 1,641
Default Vbscript help

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
__________________

__________________
Thermaltake ARMOR/ mATX intelG33 Motherboard/4gb G.SKILL High Gaming Performance ddr2-1200/Radeon 3870 1gb edition/850w Thermaltake superduty psu

PokerDegenerate: Don't listen to these guys, I like the IDE makes it look vintage like a 68 Camaro SS...
Spec is offline   Reply With Quote
Old 10-01-2007, 04:26 PM   #2
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: Vbscript help

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.
__________________

j03 is offline   Reply With Quote
Old 10-01-2007, 08:12 PM   #3
Fully Optimized
 
Spec's Avatar
 
Join Date: Aug 2005
Posts: 1,641
Default Re: Vbscript help

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.
__________________
Thermaltake ARMOR/ mATX intelG33 Motherboard/4gb G.SKILL High Gaming Performance ddr2-1200/Radeon 3870 1gb edition/850w Thermaltake superduty psu

PokerDegenerate: Don't listen to these guys, I like the IDE makes it look vintage like a 68 Camaro SS...
Spec is offline   Reply With Quote
Old 10-01-2007, 09:15 PM   #4
Daemon Poster
 
xtremezx2's Avatar
 
Join Date: Sep 2006
Posts: 915
Default Re: Vbscript help

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
xtremezx2 is offline   Reply With Quote
Old 10-01-2007, 09:26 PM   #5
Fully Optimized
 
Spec's Avatar
 
Join Date: Aug 2005
Posts: 1,641
Default Re: Vbscript help

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.
__________________
Thermaltake ARMOR/ mATX intelG33 Motherboard/4gb G.SKILL High Gaming Performance ddr2-1200/Radeon 3870 1gb edition/850w Thermaltake superduty psu

PokerDegenerate: Don't listen to these guys, I like the IDE makes it look vintage like a 68 Camaro SS...
Spec is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 10:52 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0