Skip to content

Instantly share code, notes, and snippets.

@vjeffz
Created October 23, 2012 01:41
Show Gist options
  • Save vjeffz/3936168 to your computer and use it in GitHub Desktop.
Save vjeffz/3936168 to your computer and use it in GitHub Desktop.
Re-run a logon script
'http://community.spiceworks.com/scripts/show/823-re-run-a-logon-script
Dim objNet
Dim wshShell
Dim wshProcess
Dim domain, username, dc
Set objNet = CreateObject("WScript.NetWork")
Set wshShell = CreateObject("Wscript.Shell")
Set wshProcess = wshShell.Environment("Process")
Domain = objNet.UserDomain
UserName = objNet.UserName
DC = wshProcess("LogonServer")
Set UserObj = GetObject("WinNT://" & domain & "/" & username)
loginScript = DC & "\netlogon\" & UserObj.LoginScript
on error resume next
wshShell.run(loginscript)
Set UserObj = Nothing
set wshProcess = Nothing
set wshShell = nothing
set objNet = nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment