Page 1 of 1 1
Topic Options
#124730 - 2004-08-11 12:04 AM RUNAS and Switches
JefDye Offline
Fresh Scripter

Registered: 2004-08-10
Posts: 6
I am trying to install a microsoft patch using runas with the /quiet switch. I am trying to get the native runas command to function right within Win2k. The command works fine with no switches involved but when I add the switch to the exe I am trying to run, I get an error the I am not running runas correctly and gives me the dump of all of the runas switches. I don't care if the password is in the clear at this point. I am just trying a proof of concept for my boss.

Here is my script:
; setting debug (options: ON/OFF)
DEBUG ON
; Setting varibles

$CDROM = READVALUE("HKEY_LOCAL_MACHINE\SYSTEM\DISK","\Device\CdRom0")
if @ERROR = 0
? "Drive Letter $CDROM is used for the CDROM"
ENDIF

$hotfixexe="c:\test\ms04-020\Windows2000-KB841872-x86-ENU.exe"
$switches=" /quiet"
? $hotfixexe + $switches

run "runas.exe /user:%COMPUTERNAME%\admin " + $hotfixexe + $switches
sleep 1
sendkeys ("password{ENTER}")

quit

What am I doing wrong?

Top
#124731 - 2004-08-11 08:49 AM Re: RUNAS and Switches
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Search the board for admin scripts... You have to use the scheduler service and jt.exe
_________________________
Co


Top
#124732 - 2004-08-11 09:13 AM Re: RUNAS and Switches
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
This is just a wild guess but will it work if you enclose the command and it's switched in quotes ...

try :

Code:
$hotfixexe="'c:\test\ms04-020\Windows2000-KB841872-x86-ENU.exe"
$switches=" /quiet'"
? $hotfixexe + $switches

run "runas.exe /user:%COMPUTERNAME%\admin " + $hotfixexe + $switches
sleep 1
sendkeys ("password{ENTER}")

quit

_________________________



Top
#124733 - 2004-08-17 01:19 PM Re: RUNAS and Switches
Kilhian Offline
Fresh Scripter

Registered: 2004-08-17
Posts: 15
Is this another solution ?

Quote:


$hotfixexe="c:\test\ms04-020\Windows2000-KB841872-x86-ENU.exe"
$switches=" /quiet"
? $hotfixexe + $switches
Shell '%COMSPEC% /C 'runas /user:%COMPUTERNAME%\admin "$hotfixexe" "$switches"
sleep 1
sendkeys ("password{ENTER}")
quit




Top
#124734 - 2004-08-17 02:31 PM Re: RUNAS and Switches
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I think we are getting the wires crossed a bit here..

If we look at RUNAS with a /? we see -
Quote:


C:\Documents and Settings\Kent>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.





Now, if we look at a Microsoft patch (Start/Run with a /?), we then see how the quiet switch comes in (KB823980) -
Quote:


-u Unattended Mode
-f Force other programs to clos when the computer shuts down
-n Do no back files for uninstall
-o Overwrite OEM files without prompting
-z Do no restart when installation is complete
-q Quiet mode (no user interaction)
-l List installed hotfixes





Now, depending on the file from Microsoft, YMMV.

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#124735 - 2004-08-17 05:34 PM Re: RUNAS and Switches
JefDye Offline
Fresh Scripter

Registered: 2004-08-10
Posts: 6
So what you are saying is that I may have the switches for the patch wrong? Hmmm. When I run the patch from a command line with the /quiet switch it runs fine. Or am I just misunderstanding what you are trying to tell me.

Jef

Top
#124736 - 2004-08-17 05:37 PM Re: RUNAS and Switches
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
well if you insist on using runas inside of your script (going against what most admins on here would recommend), then i would say take a look at the runas program that can be found at the link below. Lets you put the password as a command line switch so that you dont have to use sendkeys. It also has a handy wait switch that will make it wait until the program called is completed before continuing.

http://www.anbsoftware.co.uk/netadmin/runas/

Top
#124737 - 2004-08-17 06:04 PM Re: RUNAS and Switches
JefDye Offline
Fresh Scripter

Registered: 2004-08-10
Posts: 6
Is the scheduler the most common way around this or is there something else I should be searching for to get the solution?
Top
#124738 - 2004-08-17 08:30 PM Re: RUNAS and Switches
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
yes as far as i know...the Task Scheduler type of solution is the most used. Just depends on how secure you want to be and what you consider to be secure.
Top
#124739 - 2004-08-18 05:24 AM Re: RUNAS and Switches
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also the FAQ Forum.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 533 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.061 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

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