Page 1 of 1 1
Topic Options
#189607 - 2008-09-11 03:09 PM RUNNAS.exe
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Hello looking for a little help, hopefully this will be a quick one. using the following code.
IF INGROUP("Psinstall")
$Powershell = ReadValue('HKLM\SOFTWARE\Microsoft\PowerShell\1\','Install')
If $Powershell <> 1
$server="@lserver\netlogon\bats\WindowsXP-KB926139-v2-x86-ENU.exe"
$runaspath="@lserver\netlogon\runnas.exe"
SHELL '$runaspath /user:@wksta\Administrator $server /pass:XXXXXX'
Endif
Endif
I can not get it to use the local administrator usercode and password to run the exe.. If I use a domain level account it will work.. Can you not use the local account??
_________________________
You'll never know, unless you ask.

Top
#189608 - 2008-09-11 03:19 PM Re: RUNNAS.exe [Re: Thom]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
If you type runas /? at the commnand prompt it will show you the options. One of them is user:mycahine\administrator ;\)

 Code:
H:\>runas /?
RUNAS USAGE:

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

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

   /noprofile        specifies that the user's profile should not be loaded.
                     This causes the application to load more quickly, but
                     can cause some applications to malfunction.
   /profile          specifies that the user's profile should be loaded.
                     This is the default.
   /env              to use current environment instead of user's.
   /netonly          use if the credentials specified are for remote
                     access only.
   /savecred         to use credentials previously saved by the user.
                     This option is not available on Windows XP Home Edition
                     and will be ignored.
   /smartcard        use if the credentials are to be supplied from a
                     smartcard.
   /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   program         command line for EXE.  See below for examples

Examples:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:user@domain.microsoft.com "notepad \"my file.txt\""

NOTE:  Enter user's password only when prompted.
NOTE:  USER@DOMAIN is not compatible with /netonly.
NOTE:  /profile is not compatible with /netonly.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189609 - 2008-09-11 03:23 PM Re: RUNNAS.exe [Re: Mart]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
But isn't that what I have here?

SHELL '$runaspath /user:@wksta\Administrator $server /pass:XXXXXX'

Am I doing the syntax wrong, and not seeing it?
_________________________
You'll never know, unless you ask.

Top
#189610 - 2008-09-11 03:49 PM Re: RUNNAS.exe [Re: Thom]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Sorry, my bad. Did not notice that

It could be that the macro and the variable are not expanded to the actual value they hold because they are inside quotes.

Maybe something like this would work better (did not test it)
 Code:
SHELL $runaspath + ' /user:' + @wksta + '\Administrator ' + $server + ' /pass:XXXXXX'


Edited by Mart (2008-09-11 03:51 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189611 - 2008-09-11 04:08 PM Re: RUNNAS.exe [Re: Mart]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Sadly no go.. any other thoughts? Strange that the same syntax works for domain account but not local. and yes, the administrator usercode and password are correct.
_________________________
You'll never know, unless you ask.

Top
#189612 - 2008-09-11 06:00 PM Re: RUNNAS.exe [Re: Thom]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Well here is another caveat.. It works when I have the exe on a network share. But I have to supply a domain usercode and password. Therefore the password is visable in the script.. Where this is going to be on a share that others can see, how can I make the password invisible to others or have it encrypted in the script, so they can not see it.. Is this possible?
_________________________
You'll never know, unless you ask.

Top
#189635 - 2008-09-12 02:04 PM Re: RUNNAS.exe [Re: Thom]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
If your using runnas (with 2 n's) versus runas (with 1 n), you can tokenize the command line with the /tok switch. Or even better, just tokenize the kix script itself (with the kix /t switch) ?

Edited by Shawn (2008-09-12 02:04 PM)

Top
#189640 - 2008-09-12 06:18 PM Re: RUNNAS.exe [Re: Shawn]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Shawn

I will see if I can figure that out. I am running the version with two n's.
_________________________
You'll never know, unless you ask.

Top
#189642 - 2008-09-12 06:52 PM Re: RUNNAS.exe [Re: Thom]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Shawn

Do you see anything here that would cause the /quiet switch not to work? Other than being a crappy coder I need help..

Thanks.

IF INGROUP("Psinstall")
$Powershell = ReadValue('HKLM\SOFTWARE\Microsoft\PowerShell\1\','Install')
If $Powershell <> 1
$local="%systemroot%\temp"
$server="@lserver\netlogon\bats\WindowsXP-KB926139-v2-x86-ENU.exe"
copy $server $local
$Winpath = "$local\WindowsXP-KB926139-v2-x86-ENU.exe /quiet"
$runaspath="@lserver\netlogon\runnas.exe"
SHELL $runaspath + ' /user:' + @wksta + '\Administrator ' + $winpath + ' /pass:xxxxxxxx'
Endif
Endif
_________________________
You'll never know, unless you ask.

Top
#189651 - 2008-09-13 01:50 PM Re: RUNNAS.exe [Re: Thom]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Whats not being quiet ? Are you getting a DOS box appearing or is the install itself not being quite ?
Top
#189657 - 2008-09-14 02:33 AM Re: RUNNAS.exe [Re: Shawn]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Yes, if you rub the install with the /quite switch in a dos box, you don't see anything, it go off an installs in the background.. With this, and the /quiet switch, first you see the files extract, and then the regular install program. I don't want the users to know that it is being installed.
_________________________
You'll never know, unless you ask.

Top
#189665 - 2008-09-15 01:36 AM Re: RUNNAS.exe [Re: Thom]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What if you change that last line to:

SHELL $runaspath + ' /user:' + @wksta + '\Administrator ' + '"$winpath"' + ' /pass:xxxxxxxx'

[Changed '$winpath' to '"$winpath"']

Top
#189669 - 2008-09-15 05:47 PM Re: RUNNAS.exe [Re: Shawn]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Sadly this does not work. It looks like the RuNNAs.exe does not appear to be able to handle these switches.

Humm now what.
_________________________
You'll never know, unless you ask.

Top
#189671 - 2008-09-15 07:08 PM Re: RUNNAS.exe [Re: Thom]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Would have bet the house that would work. Because your trying to pass /quiet to the install, not to runnas.

Sometimes what I do to debug these long funky concatenated strings is to just print it out to the console, to see how its being passed, like this:

$= SetOption("WrapAtEol", "On")

? $runaspath + ' /user:' + @wksta + '\Administrator ' + '"$winpath"' + ' /pass:xxxxxxxx'

The WrapAtEol ensures that the console output doesn't wrap onto itself. Try it and paste your output for us to see (minus the password of course ;0))


Top
#189673 - 2008-09-15 07:58 PM Re: RUNNAS.exe [Re: Shawn]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Here are the results.

\\XXX-ADC-03\netlogon\runnas.exe /user:TDOMBROWSKI-XPP\administrator C:\WINDOWS\temp\WindowsXP-KB926139-v2-x86-ENU.exe /quiet /pass:XXXXXXXX
_________________________
You'll never know, unless you ask.

Top
#189674 - 2008-09-15 08:42 PM Re: RUNNAS.exe [Re: Thom]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Shawn

Just so you know I tried to run the command interactively in dos, with the same results.. It just does not like the /quite switch.. Oh well, I will see if I can figure out another way thanks for the help.. I will check back to see if you had a thought.. thanks again.
_________________________
You'll never know, unless you ask.

Top
#189675 - 2008-09-15 08:48 PM Re: RUNNAS.exe [Re: Thom]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm, still don't see those quotes in their proper place - in the output line you posted.

What doesn't run quietly from the command line ?

This:

\\XXX-ADC-03\netlogon\runnas.exe /user:TDOMBROWSKI-XPP\administrator C:\WINDOWS\temp\WindowsXP-KB926139-v2-x86-ENU.exe /quiet /pass:XXXXXXXX

Or this:

C:\WINDOWS\temp\WindowsXP-KB926139-v2-x86-ENU.exe /quiet


===

That first command line should look like:

\\XXX-ADC-03\netlogon\runnas.exe /user:TDOMBROWSKI-XPP\administrator "C:\WINDOWS\temp\WindowsXP-KB926139-v2-x86-ENU.exe /quiet" /pass:XXXXXXXX


Top
#189677 - 2008-09-15 09:15 PM Re: RUNNAS.exe [Re: Shawn]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
Shawn

I think you got it.. I tried what you suggested this morn..
SHELL $runaspath + ' /user:' + @wksta + '\Administrator ' + '"$winpath"' + ' /pass:xxxxxxxx' in $winpath the /quiet was part of it.. that did not work..

I just changed it to the following

$runaspath + ' /user:@wksta\administrator ' + '"$Winpath /quiet"' + ' /pass:xxxxxx'

where /quiet is appended differently.. so far that has worked on my test machine. I will test it elsewhere.. Again thanks for the help.


Edited by Thom (2008-09-15 09:27 PM)
_________________________
You'll never know, unless you ask.

Top
#189678 - 2008-09-15 09:45 PM Re: RUNNAS.exe [Re: Thom]
Thom Offline
Fresh Scripter

Registered: 2005-11-30
Posts: 39
VICTORY....... Thanks.
_________________________
You'll never know, unless you ask.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.079 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org