Really dumb VB question....

Mainframeguy

Debiant by way of Ubuntu
Joined
29 Aug 2002
Messages
3,763
Maybe I am being too lazy to find out (I do code, just not in VB!)

But is the following a valid script to shutdown windoze XP (I have delimited with <start> and <end> - rest is pasted right out of file)...

<start>
'Begin shell script code'
set WshShell = CreateObject("WScript.Shell")

WshShell.Run "c:\windows\system32\cmd.exe"


'Wait until cmd.exe has loaded'
While WshShell.AppActivate("c:\windows\system32\cmd.exe") = FALSE
wscript.sleep 1000
Wend

'Bring cmd.exe to the foreground'
WshShell.AppActivate "c:\windows\system32\cmd.exe"

'Change directories and issue shutdown command
WshShell.SendKeys "cd{\}"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "cd windows{\}system32"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "shutdown -s"
WshShell.SendKeys "{ENTER}"

'End shell script code'
<end>

incase you wonder why... I am trying to run this when MBM jits a temperature trigger that makes my system unstable - it is not the best script, a warning window to close apps would be kind!, but I thought it was s start.... I know you guys will tell me all about it...
 
Uhm, what a waste of time to go thru all that, why not just execute shutdown directly?
 
as you do ..... really I'd like to make it highly adaptable... any suggestions?
 
Well, if you just execute shutdown -s, from the CMD, it should find the executable itself, and execute it, no need to cd or anything
 

Members online

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back