Script to run before Shut Down


  1. Posts : 1,002
    XP Pro (x86) | 7 HP (x86) & (x64) | 7 Pro (x64)
       #1

    Script to run before Shut Down


    I have a script run by a shortcut to open a specific external HD.
    If the HD is not connected shows my preferred message.
    (Loops through all drives, to identify the HD unique ID)

    How would I stage a script to run before Shut Down to capture the HD if it is still connected, and cancel Shut Down.

    Is it possible ?

    Would appreciate any help :)
      My Computer


  2. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #2

    Hi,

    Have a look at this Technet link. Hopefully will tell you everything you need.

    http://technet.microsoft.com/en-us/l.../cc770300.aspx

    Tanya
      My Computer


  3. Posts : 1,002
    XP Pro (x86) | 7 HP (x86) & (x64) | 7 Pro (x64)
    Thread Starter
       #3

    Thanks TanyaC for your response :)

    I failed to tell you I am using Win7 Home Premium. Obviously no Group Policy.
    -----
    EDIT
    -----
    Just found ...
    At Open the Local Group Policy Editor I found ...

    To open the Local Group Policy Editor as an MMC snap-in
    1. Open MMC. (Click Start , click in the Start Search box, type mmc , and then press ENTER .)
    2. On the File menu, click Add/Remove Snap-in .
    3. In the Add or Remove Snap-ins dialog box, click Group Policy Object Editor , and then click Add .
    4. In the Select Group Policy Object dialog box, click Browse .
    5. Click This computer to edit the Local Group Policy object, or click Users to edit Administrator, Non-Administrator, or per-user Local Group Policy objects.
    6. Click Finish .
    Would this process enable me to run my script as planned -- OR AM I snookered with Home Premium ?
    Last edited by bawldiggle; 18 Dec 2013 at 22:43. Reason: updated info
      My Computer


  4. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #4

    Hi,

    Yes, this is another way to access the group policy editor, assuming the snap in is installed on Home Premium. All my computers were either professional or ultimate so I always had access to the GPO.

    In any case, even if you cannot get access to the GP editor all is not lost, because for the most part it is simply an interface to the registry, and generally speaking mosst things you can do with GP Editor can be done with manual registry entries.

    I found this example discussing how to do it via the registry.. (It is a bit technical), if you can't run the GPO from MMC and want have a go via the registry, make sure you back it up first, or at least create a restore point.

    http://en.kioskea.net/faq/3358-execu...p-and-shutdown

    (Credit to Kioskea.net for the code).

    Get back to us if you need more help with this.

    Edit: The only thing I'm not sure of is if Windows Home Premium will honour the scripts, but reading through the KioskEa.net solution , it certainly implies it will.

    HTH
    Tanya
      My Computer


  5. Posts : 1,002
    XP Pro (x86) | 7 HP (x86) & (x64) | 7 Pro (x64)
    Thread Starter
       #5

    Thanks TanyaC,

    So close to Xmas it will be a week or two before I can get to "my script" experiment.
    I have been out of the country for about 8 weeks (not holidays) and my daughter is on my case to downgrade her Win8 Dell, to Win7.

    I will get back here when I get the script working.

    One question, can I suspend "Shut Down" with script or is shut-down inevitable.?
      My Computer


  6. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #6

    GrayGhost2 said:
    Thanks TanyaC,
    One question, can I suspend "Shut Down" with script or is shut-down inevitable.?
    Let's say your script says "Shutdown /s /t 30"

    If you intercept that shutdown command before the 30 seconds expires with "shutdown /a" it will cancel the pending shutdown.

    I always use a value > 0 when I used automated shutdowns, because that gives you the chance to cancel it, but, it also gives the system time to finish of anything when the kill signal is sent to the processes, or so I'm told.

    Tanya
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:10.
Find Us