This is somthing I have to do a lot, unfortunatley due to the delegated access to the active directory in the UK we don't have direct access to Group Policy so we do a lot of things with logon scripts. It's often the case we may need to make registry tweaks or similar, for this I use AutoIT scripts as it's easy to run script with alternate credentials. The only other issue with Windows 7 is UAC for this will need to be disabled if you want to avoid the user being prompted to run the script.
http://www.autoitscript.com/site/autoit/
If Not IsAdmin() Then
If $CMDLINE[0] = 0 Or $CMDLINE[1] <> "Restart" Then
If Not RunAs("user","domain","password",1,"""" & @ScriptFullPath & """ Restart",@ScriptDir)
Then Exit 1
Exit 0
Else
Exit 1
EndIf
EndIf
This code will restart the script with the credentials you provide. I usually put the code I don't want executed as the elevated user within another if statement.
If $CMDLINE[0] = 0 Or $CMDLINE[1] <> "Restart" Then
code here
Endif
No comments:
Post a Comment