Windows 8 and 8.1 Forums


Execution of a DOS command each time a user logs off

  1. #1

    Execution of a DOS command each time a user logs off


    Hi


    In all editions of Windows 8, how do I make sure that it executes a DOS command each time a user logs off?

    Thanks

    Bye

      My System SpecsSystem Spec

  2. #2


    Posts : 480
    Windows 8 Pro x64


    DOS? Anyway, try creating a scheduled task with the Trigger at log off. Set the command on the Action tab.
    Last edited by Vadikan; 24 May 2013 at 14:53. Reason: removed "basic"
      My System SpecsSystem Spec

  3. #3


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    Make a Batch File or a Macro of that command - T%hen use Task Sched to run THAT. It works better that way, you can add command line switches.
      My System SpecsSystem Spec

  4. #4


    Posts : 480
    Windows 8 Pro x64


    XweAponX,
    You can add command line switches without a batch file, there's a special Arguments field for that in Action. E.g.
    cmd
    /c echo hello>>%userprofile%\desktop\hello.txt

    Certainly, CMD-file will work equally well.
      My System SpecsSystem Spec

  5. #5


    Maryland USA
    Posts : 758
    Windows 8 & Windows 7 Dual Boot


    Adding a user logoff script in Group Policy ( ive been trying to get this to work since this afternoon, I dont know why its not working for me, maybe youll have better luck)

    Assign user logoff scripts: Group Policy



    Audit users login, logoff, Startup, or Shutdown

    Audit users Logon/logoff as well as Startup/Shutdown with batch file


    Heres a registry edit to point to a batchfile, unfortunately its not in windows 8, Im still trying to figure it out, in the meantime i'll show you some suggestions on where to look..

    windows - Running a batch file on logoff - Super User
      My System SpecsSystem Spec

  6. #6


    By chance, in Windows 8 Standard (and in other editions), there is one registry key or entry that can perform a reg command that is executed when a user logs off? This key or entry must operate at the global level.

    Thanks

    Bye
      My System SpecsSystem Spec

  7. #7


    Posts : 480
    Windows 8 Pro x64


    balubeto,
    There's no such registry key, but a scheduled task is easy to deploy.

    Brooklyn567,
    How would you do a group policy logoff script in Windows 8 (not Pro)?
    Last edited by Vadikan; 25 May 2013 at 15:08.
      My System SpecsSystem Spec

  8. #8


    Posts : 2
    Windows 8


    I'm attempting to do something similar as well (run a vbscript to call a powershell script). However, with just the standard Windows 8 edition Group Policy Editor is not included. Task Scheduler has no event for logging off or shutting down. In fact, I can't get Task Scheduler to ever actually run a task. Even the most basic Startup task will not trigger during Startup (SOLVED).

    Has anyone figured out a way to run scripts at shutdown, or even at logoff, that doesn't require Windows 8 Pro/Server?


    Details:

    I am running a VBscript to call a PowerShell script. The purpose of which is to copy files from one drive to another.

    I've got a RAM disk where I've symbolically linked Google Chrome's \Default folder. This way every time I shut down, all the cookies, bookmarks, temp files are lost. My scripts are attempting to copy certain files like "Bookmarks" and "Last Session" from a dump folder on a hard disk, back into the RAM disk folder on Startup so I don't have to continuously import my bookmarks back into Chrome. This way everytime I shut off the machine, all the junk is lost but my bookmarks and last tab session are saved to file. Then when the machine starts up again, I've got a fresh browser with my bookmarks already imported and my last opened tabs up and going.

    I've got everything working great but the shutdown portion of my scripts. For the life of me I cannot figure out how to run a shutdown script in Windows 8 (standard edition, without Group Policy Editor). It is becoming frustrating that I can simply drop my scripts in the shell folder for Startup (but not shutdown), or go into Task Scheduler and set it to run on user login (but not user logoff/shutdown). If I can just figure out how to run a shutdown script, I'm gold!
    Last edited by SpeakerRob; 26 Sep 2013 at 19:25.
      My System SpecsSystem Spec

  9. #9


    Sloe Deth, Californicatia
    Posts : 3,908
    Windows 8 Pro with Media Center/Windows 7


    As far as using Powershell Scripts, I had a script that I used to read my Temperatures from Open Hardware Monitor, and when I set it up, it worked great, but I could never get it to run from Powershell after that, it has to be in the ISE, and even after creating it, and loading it into ISE, it would not run the way it ran the first time I ran it.

    If you can convert the Powershell script to a regular Batch file, then you can add it to Task Scheduler. Is there any way you can convert the script to a BAT?

    I was able to create a speech macro so I could tell my computer "Ribbons" and it would start the screensaver, and "Shut Up" which would tell it to shut down, I've got one for Hibernate too, that one is just "Hibernate". I've had better luck with Speech than with Powershell.
      My System SpecsSystem Spec

  10. #10


    Posts : 2
    Windows 8


    *UPDATE*

    I've come across a messy solution, which is basically creating a desktop shortcut that runs a VBscript to call my powershell script. The PowerShell script then executes and calls the system shutdown. I don't really like this solution because it doesn't account for system rebooting. Also, it restricts me to using only the shortcut to shutdown and does not run the script for any other shutdown events.

    So I've been tinkering with a second solutionl. This method involves adding registry values to basically do what Group Policy Editor does. I have not been able to get this to work however, and I'm unsure on whether it has to do with my registry hack, or the version of Windows I'm using.

    First I tried adding the script to the shutdown event:
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]    
    
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]  
    
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]    
    "GPO-ID"="LocalGPO"    
    "SOM-ID"="Local"    
    "FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"    
    "DisplayName"="myGroupPolicy"    
    "GPOName"="myGroupPolicy"
    
    
      
    
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]    
    "Script"="C:\\ShutdownScripts.vbs"    
    "Parameters"=""    
    "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
    The script does not execute. I thought maybe it had to do with the term process unloading explorer or something. I don't understand the nuts and bolts of what is going on during shutdown. So I tried this instead:

    Code:
    Windows Registry Editor Version 5.00   
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Logoff]  
    
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Logoff\0]    
    "GPO-ID"="LocalGPO"    
    "SOM-ID"="Local"    
    "FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"    
    "DisplayName"="myGroupPolicy"    
    "GPOName"="myGroupPolicy"
    
    
      
    
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Logoff\0\0]    
    "Script"="C:\\ShutdownScripts.vbs"    
    "Parameters"=""    
    "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
    Still no luck.
      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Execution of a DOS command each time a user logs off
Related Threads
Hello, I'm looking for a command prompt script or other file to be able to manually enter a time to run a file. The idea I'm looking for is to execute the script or other file, enter a time into a pop-up prompt (i.e. 9:24) and have the computer execute the file at that time. I'm looking...
Help Appreciated. In a Windows 8 PC, User account is "Standard" and Administrator account is different, in which how can I exclude some application which is from asking administrator password to execute? My situation is specially for application updates such as java and/or adobe reader....
Hi gurus Is there any way to add a command to the Windows 8.1 start button (right mouse click throws up a menu). That could be quite useful for launching something like a user tool bar from the start button. Cheers jimbo
Hi In Windows 8, it is possible to run a command whenever the login screen of the last user is displayed in a local computer? This command should always be run with elevated rights and just before this screen appears. Thanks Bye
Power-On Logs In Previous User - No Choice/UID Screen in User Accounts and Family Safety
I have 2 users - admin & non-admin. When I power on the laptop, it immediately brings me into the workspace of the last user on the machine. I never get the 'Lock' screen nor the screen which shows both users' icons. I cannot understand: XPPro used to present me with icons for all users, for me to...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook