Sign in to follow this  
Followers 0
Rex

Windows exit code

31 posts in this topic

Hi.

I have createt a logoff script, but the script runs both on reboot and on shutdown :) Is there any way i can check within the script if win is shutingdown or just rebooting ?????????????

I'd try to search on the net, but i couldent finde anything

Share this post


Link to post
Share on other sites



No one ?????????

Share this post


Link to post
Share on other sites

what OS are you running?

Share this post


Link to post
Share on other sites

what OS are you running?

<{POST_SNAPBACK}>

Hi I'm using windows XP

Share this post


Link to post
Share on other sites

Try explain your problem a little more, i coulnt understand it all.

A logoff script that runs on shutdown and reboot? :S

Share this post


Link to post
Share on other sites

cant u just put the logoffscript in c:\windows\system32\grouppolicies\scripts\usr\logoff ?

Share this post


Link to post
Share on other sites

cant u just put the logoffscript in c:\windows\system32\grouppolicies\scripts\usr\logoff ?

<{POST_SNAPBACK}>

Where do U thing i have placed it ? :D It's a logoff script :) NHF

Well xp runs the script regardles of it's a reboot or a shutdown, and i only want the script to run when i shutdown my computer

Share this post


Link to post
Share on other sites

Try explain your problem a little more, i coulnt understand it all.

A logoff script that runs on shutdown and reboot? :S

<{POST_SNAPBACK}>

I have createt a logoff script that i would like to run ONLY when xp shutsdown.

Ass fornow xp run's the scripr at both reboot and shutdown.

So i need a way to check if xp is shuting down or just reeboting

Share this post


Link to post
Share on other sites

Isn't

Computer Shutdown stored in:

C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Shutdown

And User Log Off stored in:

C:\WINDOWS\System32\GroupPolicy\User\Scripts\Logoff


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

Isn't

Computer Shutdown stored in:

C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Shutdown

And User Log Off stored in:

C:\WINDOWS\System32\GroupPolicy\User\Scripts\Logoff

<{POST_SNAPBACK}>

Yes and no

It's tru that the user logoff script has palce in C:\WINDOWS\System32\GroupPolicy\User\Scripts\Logoff.

But sins i'm the only user on my pc, i use the shutdown path, but still xp runs the script un both reboot and on shutdown.

Share this post


Link to post
Share on other sites

Checkout

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shutdown Setting


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

i think your xp is b0rked when it runs both on startup and shutdown :)

Share this post


Link to post
Share on other sites

Can you separate the code for the Logoff, and just have the Shutdown call the Logoff if you want?

I don't know much else, I haven't done much Windows Admin in a while...horrible teacher (err...babysitter, he doesn't teach)...only been running linux.


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

When windows shutdowns or reboot it does the same shutdown procedure, that is logoff the users, shutdown the OS, only difference is in the commands it passes on to the bios. But as far as the OS is concerned a cold or warm boot is the same.


CheersNobby

Share this post


Link to post
Share on other sites

I guess no one googles anymore...

This is a piece from microsoft

This behavior occurs because Windows writes this information to the following registry key every time your computer is shut down:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ Explorer\Shutdown Setting

Checking this registry key when your script is called could tell you if it was Shutdown or reboot...


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

I guess no one googles anymore...

This is a piece from microsoft

Checking this registry key when your script is called could tell you if it was Shutdown or reboot...

<{POST_SNAPBACK}>

I did google, but i must have used wrong seach word's

NM.

I'd try to read the reg but, i't seems that the reg updates after the script so i can't use it to finde out if xp is closing or rebooting.

Any other have any sug.

Share this post


Link to post
Share on other sites

What does the script do when you shutdown ?

Or what is it supposed to do ?

Just out of curiousity

Share this post


Link to post
Share on other sites

What does the script do when you shutdown ?

Or what is it supposed to do ?

Just out of curiousity

<{POST_SNAPBACK}>

Backup some data, mails - documents a.s.o.

But with a mailbox size 500Mb and 1.2Gb documents i don't want to wait for the script to backup every time i reboots :)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

IDEA: Don't use shutdown on the Start Menu. Use the following script.

- You can even remove the shutdown button from the start menu (simply kill/restart explorer.exe to see effect)

- A shutdown icon is also attached!

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
$GUI = GuiCreate("MyGUI", 203, 299,(@DesktopWidth-203)/2, (@DesktopHeight-299)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button_logoff = GuiCtrlCreateButton("Logoff", 20, 30, 150, 40)
$Button_shutdown = GuiCtrlCreateButton("Shutdown", 20, 100, 150, 40)
$Button_reboot = GuiCtrlCreateButton("Reboot", 20, 170, 150, 40)
$Checkbox_force = GuiCtrlCreateCheckbox("Force", 40, 240, 120, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    $force_status = 4 * ControlCommand($GUI, "",$Checkbox_force,"IsChecked")
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_logoff
        Shutdown(0 + $force_status)
        Exit
    Case $msg = $Button_shutdown
        Run("Your program goes here")
        Shutdown(1 + $force_status)
        Exit
    Case $msg = $Button_reboot
        Shutdown(2 + $force_status)
        Exit
    EndSelect
WEnd
Exit

shutdownIcon.ico

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

IDEA:  Don't use shutdown on the Start Menu.  Use the following script.

- You can even remove the shutdown button from the start menu (simply kill/restart explorer.exe to see effect)

- A shutdown icon is also attached!

; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
$GUI = GuiCreate("MyGUI", 203, 299,(@DesktopWidth-203)/2, (@DesktopHeight-299)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button_logoff = GuiCtrlCreateButton("Logoff", 20, 30, 150, 40)
$Button_shutdown = GuiCtrlCreateButton("Shutdown", 20, 100, 150, 40)
$Button_reboot = GuiCtrlCreateButton("Reboot", 20, 170, 150, 40)
$Checkbox_force = GuiCtrlCreateCheckbox("Force", 40, 240, 120, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    $force_status = 4 * ControlCommand($GUI, "",$Checkbox_force,"IsChecked")
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_logoff
        Shutdown(0 + $force_status)
        Exit
    Case $msg = $Button_shutdown
        Run("Your program goes here")
        Shutdown(1 + $force_status)
        Exit
    Case $msg = $Button_reboot
        Shutdown(2 + $force_status)
        Exit
    EndSelect
WEnd
Exit

<{POST_SNAPBACK}>

LOL could be a nice way to do it, but i'm not using the start button to shutdown/reboot XP i'm using ctrl+alt+del and the good old win style :D

And decide that it would me more proff. "to do it my way" :)

and i'm sure ther is a way to do it

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  
Followers 0