Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - find the current stat and reboot

Reply
 
Old 12-16-2008   #1 (permalink)
freddy


 
 

find the current stat and reboot

I would like to reboot some computer, but I need to know what state there in.
Example if computername is in the login prompt rebbot, if computer is locked
do nothing.

My System SpecsSystem Spec
Old 12-17-2008   #2 (permalink)
yehuda


 
 

RE: find the current stat and reboot

hey

as i can see it you can make any kind of decision

if user login or not

so it something like this will do the job:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
( "Select * from Win32_ComputerSystem" )

For Each objComputer In colComputer
If objComputer.UserName = "" ' no user log on
strRestart = "shutdown -r -t 0 "
Set objShell = CreateObject("WScript.Shell")
objShell.Run strRestart
Else
WScript.Quit
Next
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Find my current drive letter and execute a program from it while i VB Script
Cannot reboot after bcdedit.exe /set {current} nx AlwaysOff command Vista General
reboot vista and can't find os and hard drive Vista account administration
find current boot configuration Vista General
Vista reboot can't find OS after a application crash Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46