Jump to content
Sign in to follow this  
erezlevi

restart the computer.

Recommended Posts

erezlevi

hi,

does anyone know how can I write a script that restart a computer (win 2003 server), without using the controlsend or send function so it can run even if no one is logged on to the computer?

I need a routin restart every day at 00:00.

Thanks,

Share this post


Link to post
Share on other sites
Jos

Just schedule a "shutdown" command or if you really want a script to do it then use the Autoit3 Shutdown() command .. :D


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
erezlevi

Just schedule a "shutdown" command or if you really want a script to do it then use the Autoit3 Shutdown() command .. :D

Thanks, just found it.

Share this post


Link to post
Share on other sites
ptrex

@all

Maybe just use what is already there.

SHUTDOWN.exe

Shutdown the computer

Syntax

SHUTDOWN [logoff_option] [/m \\Computer] [options]

logoff_option:

/i Display the GUI (must be the first option) /l Log off. This cannot be used with /m or /d option /s Shutdown /r Shutdown and Restart /a Abort a system shutdown. (only during the time-out period)

/p Turn off the local computer with no time-out or warning (only with /d) /h Hibernate the local computer (only with /f ) /e Document the reason for an unexpected shutdown of a computer

options:

/m \\Computer : A remote computer to shutdown.

/t:xxx : Time until system shutdown in seconds. The valid range is xxx=0-600 seconds. [default=30]

/c "Msg" : An optional shutdown message [Max 127 chars]

/f : Force running applications to close.

This will not prompt for File-Save in any open applications.

so will result in a loss of all unsaved data!!!

/d u:xx:yy : List a USER reason code for the shutdown.

/d P:xx:yy : List a PLANNED reason code for the shutdown.

xx Specifies the major reason code (0-255)

yy Specifies the minor reason code (0-65536)

Options in bold are for Windows 2003 onlyExample:

To create a desktop shortcut that will immediately shutdown your system - set the shortcut Target Properties to:

C:\Windows\System32\shutdown.exe -s

When using this command to reboot a server, the shutdown process will normally allow about 30 seconds to ensure each running service has time to stop. The shutdown can be made faster if all the services are first halted using NET STOP

e.g.

net stop "Microsoft Exchange Internet Mail Service"

net stop "Microsoft FTP Service"

net stop "Some other Service"

SHUTDOWN /t:25 /r

Regards,

ptrex

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.