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
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
"Jerry" <je...@hotmail.com> wrote in message
news:GHjc9.179187$Yd.79...@twister.austin.rr.com...
As soon as I get to work on Tuesday, I will give this a try. I run a lot of
applications with runas. I.E. , Exchange Admin, Outlook, Snap In's etc. and
will be interested to see how it works. I will post any final code as well.
Thanks again.
<Alex K. Angelopoulos (MVP)> wrote in message
news:efMF7uZUCHA.2936@tkmsftngp13...