Restart/Shutdown Script 
Author Message
 Restart/Shutdown Script

Hi, I am looking for a script I can write into notepad
that would force a restart (I also need one to shutdown)
a computer without prompting the user.  I am not a
programmer and have limited knowledge on the subject.  
Any help would be greatly appreciated.


Wed, 13 Jul 2005 13:21:56 GMT  
 Restart/Shutdown Script
''Flags
''Bitmapped set of flags to shut the computer down. To force a command, add
the Force flag (4) to the command value. Using Force in conjunction with
Shutdown or ''Reboot on a remote computer immediately shuts down everything
(including WMI, COM, and so on), or reboots the remote computer. This
results in an indeterminate ''return value.

'Value Meaning
'0 Log Off
'0 + 4 Forced Log Off
'1 Shutdown
'1 + 4 Forced Shutdown
'2 Reboot
'2 + 4 Forced Reboot
'8 Power Off
'8 + 4 Forced Power Off

Dim  colOperatingSystems, ObjOperatingSystem
Set colOperatingSystems =
GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from
Win32_OperatingSystem")
For Each ObjOperatingSystem In colOperatingSystems
    ObjOperatingSystem.Win32Shutdown (2 + 4)
Next

Ciao
ITALIA Dante



Quote:
> Hi, I am looking for a script I can write into notepad
> that would force a restart (I also need one to shutdown)
> a computer without prompting the user.  I am not a
> programmer and have limited knowledge on the subject.
> Any help would be greatly appreciated.



Wed, 13 Jul 2005 18:22:55 GMT  
 Restart/Shutdown Script
[...]
Quote:
>    ObjOperatingSystem.Win32Shutdown (2 + 4)

                                         ^

Small point, but one should really use Or when combining flags. Yes,
addition will work so long as you ensure that each value is a single
bit, but...

Adam
--
The question of whether computers can think is just like the question of
whether submarines can swim.
                -- Edsger W. Dijkstra



Fri, 15 Jul 2005 18:52:20 GMT  
 Restart/Shutdown Script

Quote:
> I am not a
> programmer and have limited knowledge on the subject.  
> Any help would be greatly appreciated.

My answer to " I am not a programmer" is always the same. Try starting
with AutoIt. It is a gateway to programming IMO.

http://www.hiddensoft.com/autoit/

Scripts compile to EXE starting at 41K. The script that would reboot
is as such....

ShutDown,2

from the help file...
++++++++++++++++++++++++++++++++++++++++++++
Shutdown, <Flag>

This command allows you to perform various forms of shutdown.  The
type is determined by <Flag>.  The flag can be a combination from the
table below:

Function / Flag
------------------------------
Log off the current user / 0
Shutdown the workstation / 1
Reboot the workstation / 2
Force closing of applications (may lose unsaved work) / 4
Shutdown and power off (if supported) / 8

e.g. To shutdown and force applications to close without saving =
Shutdown + Force = 1 + 4 = 5:
Shutdown, 5
++++++++++++++++++++++++++++++++++++++++++



Fri, 15 Jul 2005 22:56:52 GMT  
 Restart/Shutdown Script

Quote:
> Dim  colOperatingSystems, ObjOperatingSystem
> Set colOperatingSystems =
> GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from
> Win32_OperatingSystem")
> For Each ObjOperatingSystem In colOperatingSystems
>     ObjOperatingSystem.Win32Shutdown (2 + 4)
> Next

Why on earth does that GetObject call return a collection?  Is there likely
to be more than one operating system returned??


Sat, 16 Jul 2005 00:42:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Shutdown and Restart Windows 95 and NT for VB Script

2. Shutdown and restart windows

3. Can I vbscript a system shutdown/restart?

4. Shutdown and Restart

5. Windows 2000 Pro - Shutdown/Restart PC

6. Shutdown and Restart

7. shutdown/restart windows

8. Can anybody send VB.net Code to shutdown or restart local computer for me

9. logoff, restart, shutdown

10. Shutdown, Restart & Relogon from Vb4

11. ShutDown, Logoff, Restart ? How

12. windows95 shutdown/wait/restart?

 

 
Powered by phpBB® Forum Software