Jump to content
Sign in to follow this  
RedneckTech

Run shutdown.exe

Recommended Posts

RedneckTech

so my sisters leave the computer on all the time and ive had a request to make a script. after time=x. heres what ive got:

#include <Timers.au3>
#include <Date.au3>

$Timeout = $desiredtime
$File = "C:\ShutdownLog\Log.txt"
$Directory = "C:\ShutdownLog"
$uFile = @UserProfileDir & "\SDLog.txt"
$FileHandle = FileOpen($File, 1)
$uFileHandle = FileOpen($uFile, 1)
If FileExists($File) = 0 Then
   DirCreate($Directory)
EndIf
While 1
   $TimeIdle = _Timer_GetIdleTime()
   If $TimeIdle >= $Timeout Then
   FileWriteLine ($FileHandle, "Shutdown at: " & _NowCalc() & " Logged on user was: " & @UserName)
   FileWriteLine ($uFileHandle, "Shutdown at: " & _NowCalc() & " while you were logged on")
   Run (@ComSpec & " /c " & "Shutdown.exe -s -t 01", "", @SW_HIDE)
   EndIf
WEnd

main problem is the line:

Run (@ComSpec & " /c " & "Shutdown.exe -s -t 01", "", @SW_HIDE)

when it runs the computer just sits, and sits, and sits at the shutdown window to the point of holding the power button after 20 min. and before that i get popups saying that the process has failed to start. Test System = Win7 Pro and final system = Winxp home.

any ideas whats wrong with this?

Share this post


Link to post
Share on other sites
somdcomputerguy

Try using AutoIt's native Shutdown() function.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
RedneckTech

oo. thank you. did not know about that one... difference between shutdown and powerdown? (1 & 8 respectively)

Share this post


Link to post
Share on other sites
somdcomputerguy

difference between shutdown and powerdown?

Try them one at a time and see what happens. I would guess that it's simply two different ways to do the same thing, but I do not know exactly.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
RedneckTech

thanks man.

Share this post


Link to post
Share on other sites
RedneckTech

oo. thanks for the heads up. thats important.. thanks

will be edited as such

Share this post


Link to post
Share on other sites
somdcomputerguy

Yes, 69355, thank you for clarifying that.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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  

×