Jerry,
I haven't used SFIMpersonator, but here's what I can tell you. I
grabbed Novell's notes on this, available from:
http://www.novell.com/coolsolutions/zenworks/features/trenches/tr_win2k_
profiles_zw.html
They include a couple of demo scripts.
Basically, here's how it works. SFImpersonator has 2 methods,
Impersonate and RevertToSelf. You call the Impersonate method,
supplying it with username, password, domain, and *type of
logon* -interactive, etc -.
As soon as the Impersonate is successfully called, the script is now in
the context of another user.
That means you just run the commands as you normally would in a script
after putting on your "Admin hat" via SFImpersonator.
Here's an example:
' SFImpersonator constants:
Const LOGON_INTERACTIVE = 2, LOGON_NETWORK = 3, _
LOGON_BATCH = 4, LOGON_SERVICE = 5
domain = "domain1"
password = "mypassword
' Using your formula for username:
Set Net = CreateObject("WScript.Network")
username = "-adm-" & Net.UserName
Set SF = CreateObject("SFImpersonator.Impostor")
' we want interactive logon to use a GUI app...
SF.Impersonate username, password, domain, LOGON_INTERACTIVE
' We are now logged on as a new user within this script's process
' Run the app; no need to wait for it to complete
Set Sh = CreateObject("WScript.Shell")
Sh.Run "mmc %windir%\system32\dsa.msc", 1, False
' Now switch back to our own account before we exit.
' Note that the MMC window is still running as the admin account
SF.RevertToSelf
--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
Quote:
> Here is a batch file and a script I use for a RunAs command to open a
> couple of program with my admin accounts. How would I incorporate them
with
> the SFImpersonator code from Craig Washington's site?
> Batch File
> %windir%\System32\runas.exe /user:domain1\-adm-%username% "mmc
> %windir%\system32\dsa.msc
> vbscript
> wshshell.run "%windir%\system32\runas.exe /user:domain1\-adm-jerry
> C:\WINNT\regedit.exe" , 1 , True
> Thanks
> Jerry