| Windows 7: Can I force a user to log off automatically through a logon script? |
30 Jan 2013
|
| | Windows Professional 32 & 64 2 posts |
Can I force a user to log off automatically through a logon script? Hi there
I've trying to invoke a fix on the fly and have got a mixed windows workstation environment on my network. For particular reasons, I don't want my windows XP users to use a Windows 7 machine and equally I don't want a Windows 7 user to use a Windows XP machine. Silly I know but there you go.
I've set up a couple of WMI filters that determine the machine type and have used the following script to ensure that each user type is logged off and the PC restarted. Option Explicit
Dim objShell
MsgBox"The detected logon method is not supported " & chr(13) & chr(13) & "Please revert to using your own computer." & chr(13) & chr(13) & "This computer will now restart" & chr(13) & chr(13),0,"Invalid Logon Detected."
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -f -t 0"
For the Windows XP users on Windows 7 machines it works fine, however when a Windows 7 user logs into a Windows XP machine, it displays the message but won't do the restart bit on the Windows 7 machines.
Do I need to create some elevated permissions for my windows 7 machines. | My System Specs |
| System Manufacturer/Model Number HP 6200 SFF OS Windows Professional 32 & 64 CPU Core i3 Motherboard HP Memory 4GB Graphics Card on board Sound Card on board |
30 Jan 2013
|
| | Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 6,947 posts SecretCity |
Try to run interactively. C:\WINDOWS\system32\shutdown.exe -r -f -t 0 works on winxp? ------------
Why did you create those user accounts? You don't let them logon! You don't simply log them off but even shutdown. | My System Specs | | Computer type Laptop System Manufacturer/Model Number ACER ASPIRE 5742G OS Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 CPU Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz Motherboard Acer Aspire 5742G Memory 4,00 GB Graphics Card ATI Mobility Radeon HD 5400 Series Sound Card (1) AMD High Definition Audio Device (2) Realtek High Defi Screen Resolution 1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz Hard Drives WDC WD5000BEVT-22ZAT0 |
30 Jan 2013
|
| | Windows Professional 32 & 64 2 posts |
Sorry but I don't understand what you mean by running that command interactively.
I need this shutdown/restart facility to run as they log in (i.e. Automatically).
I can't run the command for them.
It needs to be automated as the users log in. | My System Specs | | System Manufacturer/Model Number HP 6200 SFF OS Windows Professional 32 & 64 CPU Core i3 Motherboard HP Memory 4GB Graphics Card on board Sound Card on board |
30 Jan 2013
|
| | Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 6,947 posts SecretCity |

Quote: Originally Posted by Coachie Sorry but I don't understand what you mean by running that command interactively.
I need this shutdown/restart facility to run as they log in (i.e. Automatically).
I can't run the command for them.
It needs to be automated as the users log in.  In winxp open command prompt and type C:\WINDOWS\system32\shutdown.exe -r -f -t 0
That reboots computer fine? | My System Specs | | Computer type Laptop System Manufacturer/Model Number ACER ASPIRE 5742G OS Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 CPU Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz Motherboard Acer Aspire 5742G Memory 4,00 GB Graphics Card ATI Mobility Radeon HD 5400 Series Sound Card (1) AMD High Definition Audio Device (2) Realtek High Defi Screen Resolution 1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz Hard Drives WDC WD5000BEVT-22ZAT0 |
30 Jan 2013
|
| | Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 6,947 posts SecretCity |
Why did you create those user accounts? You don't let them logon! What should they be able to do with that account? | My System Specs | | Computer type Laptop System Manufacturer/Model Number ACER ASPIRE 5742G OS Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 CPU Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz Motherboard Acer Aspire 5742G Memory 4,00 GB Graphics Card ATI Mobility Radeon HD 5400 Series Sound Card (1) AMD High Definition Audio Device (2) Realtek High Defi Screen Resolution 1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz Hard Drives WDC WD5000BEVT-22ZAT0 |
30 Jan 2013
|
| | Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 6,947 posts SecretCity |

Quote: Originally Posted by Coachie Hi there
I've trying to invoke a fix on the fly and have got a mixed windows workstation environment on my network. For particular reasons, I don't want my windows XP users to use a Windows 7 machine and equally I don't want a Windows 7 user to use a Windows XP machine. Silly I know but there you go.
I've set up a couple of WMI filters that determine the machine type and have used the following script to ensure that each user type is logged off and the PC restarted. Option Explicit Dim objShell MsgBox"The detected logon method is not supported " & chr(13) & chr(13) & "Please revert to using your own computer." & chr(13) & chr(13) & "This computer will now restart" & chr(13) & chr(13),0,"Invalid Logon Detected." Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -f -t 0"
For the Windows XP users on Windows 7 machines it works fine, however when a Windows 7 user logs into a Windows XP machine, it displays the message but won't do the restart bit on the Windows 7 machines.
Do I need to create some elevated permissions for my windows 7 machines. If a winxp user (only allowed to logon on winxp machine) logs on on Windows 7 machine .. script works? Are you very sure?! Startup scripts run NOT elevated, so can't shutdown. | My System Specs | | Computer type Laptop System Manufacturer/Model Number ACER ASPIRE 5742G OS Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 CPU Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz Motherboard Acer Aspire 5742G Memory 4,00 GB Graphics Card ATI Mobility Radeon HD 5400 Series Sound Card (1) AMD High Definition Audio Device (2) Realtek High Defi Screen Resolution 1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz Hard Drives WDC WD5000BEVT-22ZAT0 |
30 Jan 2013
|
| | Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 1,910 posts NC, USA |
It looks like the syntax might have changed since XP, and the "-" for XP is a "/" for Windows 7 switches.
Take a look here, and try using the "/" for Win 7. MS-DOS shutdown command help
For XP you might need objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -f -t 0"
For Windows 7 you might need objShell.Run "C:\WINDOWS\system32\shutdown.exe /r /f /t 0" | My System Specs | | Computer type PC/Desktop System Manufacturer/Model Number home built OS Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 CPU AMD Athlon II x4 620 Motherboard Gigabyte GA-MA785G-UD3H Memory 6GB GSkill DDR2 800 Graphics Card AMD 4670 GPU + AMD 4200 IGP Sound Card on board Realtek ALC889A Monitor(s) Displays RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor Screen Resolution 1680 x 1050... Keyboard Gyration wireless, Logitech wireless, Dell USB wired Mouse Gyration wireless, Logitech wireless, V7 USB wired PSU Corsair 500 W Case Rosewill mid tower Cooling CM 90mm Tower Hard Drives OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ... Internet Speed Uverse - 12Mbps D / 1.5Mbps U Antivirus Avast free OR MSE. (+ MBAM Pro). Browser 1-Firefox, 2-IE. (Chrome and Opera for testing) Other Info 2 PCs: Primary: dual-boot, Test: triple-boot.
Mainly HTPC/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.
Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.
Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner. |
30 Jan 2013
|
| | Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 1,910 posts NC, USA |
I tested both of these commands from a Command Prompt (CMD) window in Win 7, and they both restarted my PC.
So now I don't think it's the "-" vs "/" issue.
fyi, I log in as a Standard User, and did NOT use an elevated CMD.
Can you add a debug or trace statement to your script to see what, if anything, it returns for troubleshooting? | My System Specs | | Computer type PC/Desktop System Manufacturer/Model Number home built OS Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 CPU AMD Athlon II x4 620 Motherboard Gigabyte GA-MA785G-UD3H Memory 6GB GSkill DDR2 800 Graphics Card AMD 4670 GPU + AMD 4200 IGP Sound Card on board Realtek ALC889A Monitor(s) Displays RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor Screen Resolution 1680 x 1050... Keyboard Gyration wireless, Logitech wireless, Dell USB wired Mouse Gyration wireless, Logitech wireless, V7 USB wired PSU Corsair 500 W Case Rosewill mid tower Cooling CM 90mm Tower Hard Drives OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ... Internet Speed Uverse - 12Mbps D / 1.5Mbps U Antivirus Avast free OR MSE. (+ MBAM Pro). Browser 1-Firefox, 2-IE. (Chrome and Opera for testing) Other Info 2 PCs: Primary: dual-boot, Test: triple-boot.
Mainly HTPC/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.
Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.
Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner. |
30 Jan 2013
|
| | Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 6,947 posts SecretCity |
You better use ntrights.exe to prevent users to logon interactively. Code: ntrights -U "User or Group" +R SeDenyInteractiveLogonRight For example: Code: ntrights -U "JohnDoe" +R SeDenyInteractiveLogonRight To revert this: Code: ntrights -U "JohnDoe" -R SeDenyInteractiveLogonRight Place ntrights.exe in c:\windows\system32.
Run from command prompt in winxp. In Windows 7 run from Elevated Command Prompt
Works? | My System Specs | | Computer type Laptop System Manufacturer/Model Number ACER ASPIRE 5742G OS Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1 CPU Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz Motherboard Acer Aspire 5742G Memory 4,00 GB Graphics Card ATI Mobility Radeon HD 5400 Series Sound Card (1) AMD High Definition Audio Device (2) Realtek High Defi Screen Resolution 1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz Hard Drives WDC WD5000BEVT-22ZAT0 Can I force a user to log off automatically through a logon script? problems? All times are GMT -5. The time now is 08:33 AM. | |