scotitpulsa
IS-IT--Management
here is the snippet. if i don't have sub and end sub commmented out, it skips right over it...
'Sub main(args)
Dim user
Dim domain
Dim password
'' set these in your environment, or here in the script
'' If you're running as a service, you will need to set these
'' as SYSTEM variables
user = "**********"
domain = "**********"
password = "**********"
'' logon as user X
Dim hToken
hToken = LogonUser(user,domain,password) ',LOGON32_LOGON_BATCH,LOGON32_PROVIDER_DEFAULT)
'' Impersonate user X
Dim ilu
ilu = ImpersonateLoggedOnUser(hToken)
'' do whatever you want to do as user X
If ilu = true Then
'Print ("This thread is now running as " + user)
dim feedback_old, intranet_old, nextish_old, pulsabg_old
feedback_old = "c:\documents and settings\all users\desktop\feedback.url"
'intranet_old = "c:\documents and settings\all users\desktop\Rochester Intranet.url"
'nextish_old = "c:\nextish.ico"
'pulsabg_old = "c:\pulsabg.gif"
if fs.fileexists(feedback_old) = true then
set feedback_old = fs.GetFile(feedback_old)
feedback_old.delete
end if
'if fs.fileexists(intranet_old) = true then
' set intranet_old = fs.GetFile(intranet_old)
' intranet_old.delete
'end if
'if fs.fileexists(nextish_old) = true then
' set nextish_old = fs.GetFile(nextish_old)
' nextish_old.delete
'end if
'if fs.fileexists(pulsabg_old) = true then
' set pulsabg_old = fs.GetFile(pulsabg_old)
' pulsabg_old.delete
'end if
msgbox("impersonation succeeded")
Else
'Print ("Unable to become " + user)
msgbox("impersonation failed")
End If
'' all done with this user
FreeHandle(hToken)
'' terminate impersonation for this thread
RevertToSelf
'End Sub
'Sub main(args)
Dim user
Dim domain
Dim password
'' set these in your environment, or here in the script
'' If you're running as a service, you will need to set these
'' as SYSTEM variables
user = "**********"
domain = "**********"
password = "**********"
'' logon as user X
Dim hToken
hToken = LogonUser(user,domain,password) ',LOGON32_LOGON_BATCH,LOGON32_PROVIDER_DEFAULT)
'' Impersonate user X
Dim ilu
ilu = ImpersonateLoggedOnUser(hToken)
'' do whatever you want to do as user X
If ilu = true Then
'Print ("This thread is now running as " + user)
dim feedback_old, intranet_old, nextish_old, pulsabg_old
feedback_old = "c:\documents and settings\all users\desktop\feedback.url"
'intranet_old = "c:\documents and settings\all users\desktop\Rochester Intranet.url"
'nextish_old = "c:\nextish.ico"
'pulsabg_old = "c:\pulsabg.gif"
if fs.fileexists(feedback_old) = true then
set feedback_old = fs.GetFile(feedback_old)
feedback_old.delete
end if
'if fs.fileexists(intranet_old) = true then
' set intranet_old = fs.GetFile(intranet_old)
' intranet_old.delete
'end if
'if fs.fileexists(nextish_old) = true then
' set nextish_old = fs.GetFile(nextish_old)
' nextish_old.delete
'end if
'if fs.fileexists(pulsabg_old) = true then
' set pulsabg_old = fs.GetFile(pulsabg_old)
' pulsabg_old.delete
'end if
msgbox("impersonation succeeded")
Else
'Print ("Unable to become " + user)
msgbox("impersonation failed")
End If
'' all done with this user
FreeHandle(hToken)
'' terminate impersonation for this thread
RevertToSelf
'End Sub