Announcement

Collapse
No announcement yet.

Execution of a DOS command each time a user logs off

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    balubeto

  • #2
    Re: Execution of a DOS command each time a user logs off

    DOS has not existed for several operating systems, but in Win8 Pro you can run a CMD script as a logoff script, either via a domain GPO or a local policy
    Lower versions do not support policies but you may be able to do something with scheduled tasks
    Last edited by Ossian; 24th May 2013, 19:10.
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Execution of a DOS command each time a user logs off

      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
      balubeto

      Comment


      • #4
        Re: Execution of a DOS command each time a user logs off

        Not as far as I know, but a workaround would be to identify an event that fires at logoff (and only at logoff) and attach a scheduled task to that event.

        I thought you were wanting to run a CMD script, so not sure what you mean by "perform a reg command"

        Could you perhaps explain WHY you are trying to do this and WHAT the script is designed to achieve, and maybe someone can suggest an alternative.
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Execution of a DOS command each time a user logs off

          Originally posted by Ossian View Post
          Not as far as I know, but a workaround would be to identify an event that fires at logoff (and only at logoff) and attach a scheduled task to that event.

          I thought you were wanting to run a CMD script, so not sure what you mean by "perform a reg command"

          Could you perhaps explain WHY you are trying to do this and WHAT the script is designed to achieve, and maybe someone can suggest an alternative.
          In practice, in Windows 8, there is the Enabled item in the registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Aut hentication\LogonUI\UserSwitch that takes the value 0 whenever a user logs off. Since the group policies do not exist in Windows 8 Standard, I looking for a registry key or item, which operates at the global level, in order to make sure that the "reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Aut hentication\LogonUI\UserSwitch /v Enabled /t REG_DWORD /d 1 /f" command is executed when a user logs off.

          Thanks

          Bye
          balubeto

          Comment


          • #6
            Re: Execution of a DOS command each time a user logs off

            See previous answer and trigger the script to add the registry key based on an event
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd
            Scotland

            ** Remember to give credit where credit is due and leave reputation points where appropriate **

            Comment


            • #7
              Re: Execution of a DOS command each time a user logs off

              Originally posted by balubeto View Post
              [...]
              In practice, in Windows 8 registry there is an item called Enabled in the key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ Authentication\LogonUI\UserSwitch that takes the value 0 whenever a user logs off.

              Since the group policies do not exist in Windows 8 Standard, I am looking for an other way to launch the command "reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\ CurrentVersion\Authentication\LogonUI\UserSwitch" /v Enabled /t REG_DWORD /d 1 /f" when a user logs off.
              [...]
              A normal Windows logoff script would not have worked anyway, because logoff scripts run with the permissions of the user. Regular users do not have permission to edit the HKLM keys.

              Actually the item takes the value 0 when the user logs in and not when a user logs off.

              With the default setting (so where the item "Enabled" has already the value '0' when the computer starts) Windows 8 will show at startup, only the last user that was signed in (if that user does have a password). You can click on the back arrow button to see all users.
              But if the user that was last signed in does NOT have a password, then Windows 8 will at startup automatically sign in to that user account. Then you can only see all users after the user signed out first.

              It works best if the value would be changed at user logon.
              Running a scheduled task will do the job. As also suggested as answer by Ossion in a similar question that you posted earlier: http://forums.petri.com/showthread.p...258#post273258
              Code:
              Execute task: as an admin 
              and running with the highest privileges
              whether the admin is logged in or not
              Triggered: "At log on"
              Action: 'Start a program': Reg.exe 
              'Add arguments': ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\UserSwitch" /v Enabled /t REG_DWORD /d 1 /f
              If you can't use GPP, you can export the task to an xml file, then use a schtasks.exe command to push it out.



              So for this case you should run the job At log on.
              Additionally, if there would be other tasks that you do have to run at logoff, then the trigger of the scheduled task should be 'On an event'
              Log: System
              Source: Winlogon
              Event ID: 7002
              (is when the user is signing out. It will not be triggered when the user restarts the computer).

              /Rems

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: Execution of a DOS command each time a user logs off

                A curiosity:

                In Windows 8, I am creating a scheduled task:



                When confirm all dialog windows, the error message "unsupported request" is displayed. How come?

                Thanks

                Bye
                balubeto

                Comment


                • #9
                  Re: Execution of a DOS command each time a user logs off

                  In practice, in the XML tab of the window "edit event filter", this query:

                  Code:
                  <QueryList>
                    <Query Id="0" Path="Microsoft-Windows-Winlogon/Diagnostic">
                      <Select Path="Microsoft-Windows-Winlogon/Diagnostic">*[System[Provider[@Name='Microsoft-Windows-Winlogon'] and (Level=4 or Level=0) and Task = 1102 and (EventID=7002)]]</Select>
                      <Select Path="Microsoft-Windows-Winlogon/Operational">*[System[Provider[@Name='Microsoft-Windows-Winlogon'] and (Level=4 or Level=0) and Task = 1102 and (EventID=7002)]]</Select>
                      <Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Winlogon'] and (Level=4 or Level=0) and Task = 1102 and (EventID=7002)]]</Select>
                    </Query>
                  </QueryList>
                  is displayed.

                  When, but, confirm all dialog windows, the error message "unsupported request" is displayed. How come?

                  Thanks

                  Bye
                  balubeto

                  Comment


                  • #10
                    Re: Execution of a DOS command each time a user logs off

                    Firstly, this is not the correct solution as it will not help to show all users on the welcom screen. The trigger you should choose is "At logon" and not "By Event".
                    If a solution was helpfull please let us know.



                    OK, if you are testing an 'At logoff' trigger just out of curiousity then
                    1) why dit you select "Custom settings" to configure an event instead of "Basic settings"? Why do this test more complicated as needed.

                    btw: the - "Path="Microsoft-Windows-Winlogon/Diagnostic" - is by default not present! This will also give an error message (other error than the one you showed though), but will also cause the task can not be saved. You should manually remove invalid paths from the Query.

                    2) I can see from the print screen image there was already an other trigger configured, the problem could also be with that trigger or because there's a conflicte between the two. We can't tell.

                    3) I do not know the error message, did you translate it from the original message? There should also be an error code with it right?

                    -

                    If you replace the Querylist from your previous post with the one below, it will bring the trigger back to the correct 'basics':

                    Code:
                    <QueryList>
                      <Query Id="0" Path="System">
                        <Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Winlogon'] and EventID=7002]]</Select>
                      </Query>
                    </QueryList>
                    And make it the only trigger for this task.


                    Just to be sure, check the system log in the event viewer if there acutally are winlogon events recored with ID 2007. If not then CEIP (Windows Customer Experience Improvement Program settings) may have been disabled on you computer (is enabled by default). You can check this via Control pannel and search for: Action Center. Then click Change Action Center settings. And under Related settings, click Customer Experience Improvement Program settings.



                    /Rems
                    Last edited by Rems; 12th June 2013, 12:07.

                    This posting is provided "AS IS" with no warranties, and confers no rights.

                    __________________

                    ** Remember to give credit where credit's due **
                    and leave Reputation Points for meaningful posts

                    Comment


                    • #11
                      Re: Execution of a DOS command each time a user logs off

                      I can not understand why if I edit the registry in this way:

                      Code:
                      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
                      "Userinit"="C:\\Windows\\system32\\userinit.exe,C:\\Windows\\System32\\reg.exe add HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\UserSwitch /v Enabled /t REG_DWORD /d 1 /f,"
                      "LegalNoticeText"=""
                      "Shell"="explorer.exe"
                      "LegalNoticeCaption"=""
                      "DebugServerCommand"="no"
                      "ForceUnlockLogon"=dword:00000000
                      "ReportBootOk"="1"
                      "VMApplet"="SystemPropertiesPerformance.exe /pagefile"
                      "AutoRestartShell"=dword:00000001
                      "PowerdownAfterShutdown"="0"
                      "ShutdownWithoutLogon"="0"
                      "Background"="0 0 0"
                      "PasswordExpiryWarning"=dword:00000005
                      "CachedLogonsCount"="10"
                      "WinStationsDisabled"="0"
                      "PreCreateKnownFolders"="{A520A1A4-1780-4FF6-BD18-167343C5AF16}"
                      "scremoveoption"="0"
                      "DisableCAD"=dword:00000001
                      "ShutdownFlags"=dword:80000027
                      "EnableFirstLogonAnimation"=dword:00000001
                      "AutoLogonSID"="S-1-5-21-3137485388-3153590309-3382964295-1001"
                      "LastUsedUsername"="Balubeto_Balubeto"
                      "AutoAdminLogon"="0"
                      "DefaultUserName"="Balubeto_Balubeto"
                      the screen, which displays all accounts, does not appear.

                      Thanks

                      Bye
                      balubeto

                      Comment

                      Working...
                      X