Windows 10 Home Shutdown Script


  1. Posts : 2
    Windows 7
       #1

    Windows 10 Home Shutdown Script


    Is it possible to run a script on shutdown on Windows 10 Home edition?
    Group Policy Editor (gpedit.msc) is not available.

    Already tried to modify registry
    Execute a script a startup and shutdown
    Tested successfully on Windows 10 Professional but won't work on Home.

    Also, tried through Task Scheduler without success
    Ramblings...: How to run a script on logout/shutdown in windows 7

    Any help would be great!

    Thanks in advance
      My Computer


  2. Posts : 2
    Windows 10 Home Edition (among others)
       #2

    Better late than never, I suppose.

    Since I only needed a script to run when a user was logged in and a (hybrid or otherwise) shutdown started, I was able to solve the problem using AutoHotKey. You can get AutoHotKey here: https://autohotkey.com/

    My specific problem is I wanted to dismount VeraCrypt volumes before a hybrid shutdown and this is the script I used (easily modified, read the comments):

    Code:
    ; run_before_shutdown.ahk, 2017-05-09, Grismar
    ; restart as admin, if not running as admin
    if not A_IsAdmin
    {
       Run *RunAs "%A_ScriptFullPath%"
       ; exit, as new instance takes over
       ExitApp
    }
    
    ; ensure only one instance of the script is running at any one time
    #SingleInstance, Force
    ; optionally, hide the icon from the system tray
    ; #NoTrayIcon
    
    
    ; On WM_QUERYENDSESSION event (before shutdown), run OnShutDown callback.
    OnMessage(0x11, "OnShutDown")
    return
    
    
    OnShutDown(){
        ; Run your command, in my case a silent dismount of VeraCrypt volumes
        Run, "C:\Program Files\VeraCrypt\VeraCrypt.exe" /s /q /d
        ExitApp
    }
    Note: running the script will cause a UAC dialog to appear, asking for admin privileges; that's how I like it, but you could get it to run as admin with a (somewhat insecure) shortcut / batch file.

    Note: I start this script as part of a batch that also mounts some drives I want to auto-dismount, but you could run it on Windows startup for a specific user (AutoHotKey doesn't run if no user is logged on).
      My Computer


  3. Posts : 31
    Windows 10 Pro (10.0.18362)
       #3

    I do not know for sure...

    Did you try to get a copy of gpedit.msc and throw it into the Windows 10 directory to see it it "sticks"?

    I cannot state for sure 100%, but I do not see why that won't work for you.
      My Computer


  4. Posts : 2
    Windows 10 Home Edition (among others)
       #4

    There are various threads about the lack of a policy editor (or editable policies for that matter) on Windows 10 Home. Like Brink mentions in this thread Policy Editor Not Available In Win 10 Home Edition Solved - Windows 10 Forums :

    "I find that trying to add Group Policy to an unsupported edition usually ends in disaster."

    My experience is similar. And that's apart from the fact that you're adding stuff from Windows versions you didn't pay for to a Windows version that doesn't support it. That's just a baby step away from running a pirated version.

    Also, both the OP and myself indicated that we tried various alternative solutions that ended up not working, or not working correctly or reliably. Why exactly the policy editor was kept absent from 10 Home is only for Microsoft engineers to know, but it seems there's technical reasons as well as commercial ones...
      My Computer


 

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

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




Windows 10 Forums