"execute as" within a script 
Author Message
 "execute as" within a script

hi NG,

i want to run a part of my script under the account of another user but the
rest of the script has to run as administrator.

but how?

thx
   meyer-piton

______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.*-*-*.com/
      <><><><><><><>   The Worlds Uncensored News Source   <><><><><><><><>



Sun, 03 Oct 2004 16:51:10 GMT  
 "execute as" within a script
Under Windows 2000 you can issue a "runas" statement.  I'm not
sure the full syntax for it but you can just go to a command
prompt and run "runas /?" and it will tell you all you need to
know.

As for other OSs I don't know.



Quote:
> hi NG,

> i want to run a part of my script under the account of
> another user but the rest of the script has to run as
> administrator.

> but how?

> thx
>    meyer-piton



Sun, 03 Oct 2004 23:38:03 GMT  
 "execute as" within a script

Quote:
> Under Windows 2000 you can issue a "runas" statement.  I'm not
> sure the full syntax for it but you can just go to a command
> prompt and run "runas /?" and it will tell you all you need to
> know.

The runas command will prompt for a password.  There is no support for including the password in the command syntax...

C:\>runas /?
RUNAS USAGE:

RUNAS [/profile] [/env] [/netonly] /user:<UserName> program

   /profile        if the user's profile needs to be loaded
   /env            to use current environment instead of user's.
   /netonly        use if the credentials specified are for remote access only.

   program         command line for EXE.  See below for examples

Examples:

Quote:
> runas /profile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"


NOTE:  Enter user's password only when prompted.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--


Mon, 04 Oct 2004 00:05:23 GMT  
 "execute as" within a script
Hm.  Well there ya go :)  Sorry about the misleading you.  Thank
you Michael for the correction too :)



Quote:
>> Under Windows 2000 you can issue a "runas" statement.  I'm
>> not sure the full syntax for it but you can just go to a
>> command prompt and run "runas /?" and it will tell you all
>> you need to know.

> The runas command will prompt for a password.  There is no
> support for including the password in the command syntax...

> C:\>runas /?
> RUNAS USAGE:

> RUNAS [/profile] [/env] [/netonly] /user:<UserName> program

>    /profile        if the user's profile needs to be loaded
>    /env            to use current environment instead of
>    user's. /netonly        use if the credentials specified
>    are for remote access only. /user           <UserName>

>       command line for EXE.  See below for examples

> Examples:
>> runas /profile /user:mymachine\administrator cmd
>> runas /profile /env /user:mydomain\admin "mmc
>> %windir%\system32\dsa.msc" runas /env

> NOTE:  Enter user's password only when prompted.




Mon, 04 Oct 2004 03:52:44 GMT  
 "execute as" within a script
I use the following code; it sends the password to the app. You may encrypt
this script, so the password is not easy viewable.

Dim CmdToRunAsSu

wscript.arguments(0)
Dim WshSHell
set WshShell = CreateObject("WScript.Shell")
WshShell.Run(CmdToRunAsSu)
WScript.Sleep(100)
WshShell.AppActivate("runas.exe")
WScript.Sleep(100)
WshShell.SendKeys("administrator_password{ENTER}")
WScript.Sleep(100)


Quote:
> Hm.  Well there ya go :)  Sorry about the misleading you.  Thank
> you Michael for the correction too :)



> >> Under Windows 2000 you can issue a "runas" statement.  I'm
> >> not sure the full syntax for it but you can just go to a
> >> command prompt and run "runas /?" and it will tell you all
> >> you need to know.

> > The runas command will prompt for a password.  There is no
> > support for including the password in the command syntax...

> > C:\>runas /?
> > RUNAS USAGE:

> > RUNAS [/profile] [/env] [/netonly] /user:<UserName> program

> >    /profile        if the user's profile needs to be loaded
> >    /env            to use current environment instead of
> >    user's. /netonly        use if the credentials specified
> >    are for remote access only. /user           <UserName>

> >       command line for EXE.  See below for examples

> > Examples:
> >> runas /profile /user:mymachine\administrator cmd
> >> runas /profile /env /user:mydomain\admin "mmc
> >> %windir%\system32\dsa.msc" runas /env

> > NOTE:  Enter user's password only when prompted.




Sat, 09 Oct 2004 23:39:15 GMT  
 "execute as" within a script
Alternatively, if you have access to VB, check out the MS KB article
"[Q248187] HOWTO: Impersonate a User from Active Server Pages" on how to
make a security impersonation DLL that works in ASP or WSH. The DLL needs to
be registered on the machine, and called as shown in the article (yes, I
know ir's ASP specific - but the syntax is close enough that you can figure
out the differences).  The password can be embedded in the code that way.

- James


Quote:
> I use the following code; it sends the password to the app. You may
encrypt
> this script, so the password is not easy viewable.

> Dim CmdToRunAsSu

> wscript.arguments(0)
> Dim WshSHell
> set WshShell = CreateObject("WScript.Shell")
> WshShell.Run(CmdToRunAsSu)
> WScript.Sleep(100)
> WshShell.AppActivate("runas.exe")
> WScript.Sleep(100)
> WshShell.SendKeys("administrator_password{ENTER}")
> WScript.Sleep(100)



> > Hm.  Well there ya go :)  Sorry about the misleading you.  Thank
> > you Michael for the correction too :)



> > >> Under Windows 2000 you can issue a "runas" statement.  I'm
> > >> not sure the full syntax for it but you can just go to a
> > >> command prompt and run "runas /?" and it will tell you all
> > >> you need to know.

> > > The runas command will prompt for a password.  There is no
> > > support for including the password in the command syntax...

> > > C:\>runas /?
> > > RUNAS USAGE:

> > > RUNAS [/profile] [/env] [/netonly] /user:<UserName> program

> > >    /profile        if the user's profile needs to be loaded
> > >    /env            to use current environment instead of
> > >    user's. /netonly        use if the credentials specified
> > >    are for remote access only. /user           <UserName>

> > >       command line for EXE.  See below for examples

> > > Examples:
> > >> runas /profile /user:mymachine\administrator cmd
> > >> runas /profile /env /user:mydomain\admin "mmc
> > >> %windir%\system32\dsa.msc" runas /env

> > > NOTE:  Enter user's password only when prompted.




Mon, 15 Nov 2004 02:56:31 GMT  
 "execute as" within a script
Use TqcRunas.ImersonateUser() from http://www.quimeras.com
PTruco


Wed, 01 Dec 2004 04:55:55 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. executing "dynamically created" scripts

2. "extra space" appearing within words

3. "Execute" in VBscript 5 Beta2

4. error in Server.CreateObject("ASPExec.Execute")

5. "Execute" in VBscript 5 Beta2

6. "Execute" in VBscript 5 Beta2

7. inet control "Still executing last request"

8. Disabling "BACK"/"FORWARD" buttons

9. CreateObject("Excel","//server"), MsgBox output

10. Problem With "window.showmodaldialog("")"

11. Disabling "BACK"/"FORWARD" buttons

12. How to Replace("String Irregular # of space", "?", "")

 

 
Powered by phpBB® Forum Software