Log Off at end of script

So there I was, wondering how to log off from a session after I had finshed my script.
I had to run the the thing under elevated privlages and I was running it from the  "run once"
key in the registry, so I wanted it to log off ASAP.
 
I looked around and poked around and looked in my books, and then I ran across this piece of wisdom from
 
 Set oShell = CreateObject("WScript.Shell")

         oShell.Run "logoff", 0, False
Yep, as simple as that. I have tried it on Vista 32 and 64 and it works just as you would hope.

 
Advertisements

1 thought on “Log Off at end of script

  1. You could also run these, I beleive it runs on 2000/xp as well:Shutdown : rundll.exe user.exe,exitwindowsRestart: rundll.exe user.exe,exitwindowsexecLogoff : rundll.exe shell32.dll,SHExitWindowsEx 0—Shay LevyWindows PowerShell MVPhttp://blogs.microsoft.co.il/blogs/ScriptFanaticPowerShell Toolbar: http://tinyurl.com/PSToolbar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s