Created
October 23, 2012 01:41
-
-
Save vjeffz/3936168 to your computer and use it in GitHub Desktop.
Re-run a logon script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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