Remote logoff shutdown

kartoffel

New Member
I'm not sure if this is the right place, however I am trying remotely logoff the current user from my vista x64 ultimate machine upstairs to my vista x64 home premium machine downstairs.

I can easily restart or shutdown using
cmd> shutdown /r /f /p /m \\PC
or /s respectively

However you cannot use -l with -m so I can only turn the computer off to keep the kids from playing video games all day.

I remember in XP you could use the Computer Manager to connect to \\PC(or what ever it happens to be) and then right click to find shutdown properties and a logoff option. This seems to be gone in vista although I can use Computer Manager to connect to \\PC from my upstairs computer \\Nick-PC and see the users on \\PC, but with no logoff option.

I have also tried cmd> logoff "session#" /server:"name"
logoff 2 /server:\\PC

This also did not work even when instead of typing in 1,2,or 3 for whomever was logged on session id using their loggon name
logoff nick server:\\PC
also did nothing if nick was theoretically the current logged on user.

Any ideas for how to logoff the user without having to shutdown or restart the computer? This is more of a annoyance to keep people on task then restarting which waists a lot of time.
 

My Computer

Const cLogoff = 0
Const cShutdown = 1
Const cReboot = 2
Const cForceLogoff = 4
Const cForceShutdown = 5
Const cForceReboot = 6
Const cPowerOff = 8
Const cForcePowerOff = 12

strComputer = "PC"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)
Next

Seems to work for me it's a little abrupt, but I'm sure I can do more tinkering.
I did however have to enable rpc through the vista firewall to make this work. I had no idea what WMI or RPC was before this, ah the powers of Google.
 

My Computer

You could do it using Computer Management. Open Computer Management on your machine and connect to Bob's computer, then right-click on Bob's computer and select Properties. Switch to the Advanced tab, and click Settings under Startup And Recovery options. Now go to Shutdown and under Action click Log Off Current User and then OK.

Of course some things are easier to do using a script:

strComputer = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)
Next
You could do it using Computer Management. Open Computer Management on your machine and connect to Bob's computer, then right-click on Bob's computer and select Properties. Switch to the Advanced tab, and click Settings under Startup And Recovery options. Now go to Shutdown and under Action click Log Off Current User and then OK.
Of course some things are easier to do using a script:
strComputer = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)
Next
 

My Computer

System One

  • Manufacturer/Model
    Custom
    CPU
    AMD AM2 6000+
    Motherboard
    Nvidia M2N-E SLI
    Graphics Card(s)
    GeForce 7600GT
    Screen Resolution
    1280x1024
    Hard Drives
    WD
    Case
    Cooler Master
    Cooling
    Three fans
    Keyboard
    Dell Quietkey
    Mouse
    Dell Optical
    Internet Speed
    10 MBPS
That's the exact thing I found on some website, however in vista you cannot use computer management like that stated. The only way to use computer management like that is in xp or similar. The script I posted as my fix is basically that script copied and pasted saved in a .vbs the problem I had though was enabling it to run through the firewall on the target computer which I disabled rpc's block and now it works.

on a second note I wonder if you could instead of log off rather switch users so that they don't lose anything.
 

My Computer

Back
Top