Page 1 of 2 12>
Topic Options
#149390 - 2005-10-06 02:55 PM runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
RUN "runas /user:user deploy.exe "ct2""
$ReturnCode = SendKeys("password")
$ReturnCode = SendKeys("{ENTER}")

the script works when i remove "ct2" but the deploy.exe
doesn't do what i need it to do without "ct2"

the command line for the program is:"X:\Acad install\AdminImage\deploy.exe" "CT2"

Top
#149391 - 2005-10-06 03:05 PM Re: runas with quotes in the command??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Single outside, double inside. There is a FAQ on it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149392 - 2005-10-06 03:07 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
like this?
RUN 'runas /user:user deploy.exe "ct2"'

Top
#149393 - 2005-10-06 03:09 PM Re: runas with quotes in the command??
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
or even:
Code:
run 'runAs /user:nobody "X:\Acad install\AdminImage\deploy.exe" "CT2"'

_________________________
!

download KiXnet

Top
#149394 - 2005-10-06 03:29 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
no go...
with run ' runas......"ct2" ' i get the runas syntax displayed
with run " runas......"ct2" " i get
ERROR : unknown command [ct2]!
Script: Q:\adminimage\test.kix
Line : 1
Enter the password for domain\user

Top
#149395 - 2005-10-06 03:33 PM Re: runas with quotes in the command??
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, try this:
shell '%comspec% /K runAs /user:nobody "X:\Acad install\AdminImage\deploy.exe" "CT2"'
_________________________
!

download KiXnet

Top
#149396 - 2005-10-06 03:46 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
i get the syntax again
i'm also trying this

$ReturnCode = SendKeys("runas /user:domain\user deploy.exe")
$ReturnCode = SendKeys("{ENTER}")
$ReturnCode = SendKeys("password")
$ReturnCode = SendKeys("{ENTER}")

Top
#149397 - 2005-10-06 03:48 PM Re: runas with quotes in the command??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't think RunAs plays well with KiX. You won't find anyone that is serious about security using it. There are better ways to do it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149398 - 2005-10-06 03:54 PM Re: runas with quotes in the command??
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
If I do a runas /? I see that a double quote is escaped with a backslash (\), you might want to try that. Else perhaps creating a batchfile with the complete commandline for runas is an option. That batchfile could possible even be dynamically created from within KiX.
Top
#149399 - 2005-10-06 03:55 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
hmm....
what is need is a way to run a program with admin privileges, using run with different credentials is not an option because the user would have to know the admin username and pass, 3rd party programs such as tqcrunas and others are not an option because they are not approved to run on air force computers, if I can get it work with kix (preferably) or another script language I can encrypt it so the users would not be able to view the admin username or pass embedded in the script.

Top
#149400 - 2005-10-06 04:03 PM Re: runas with quotes in the command??
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
From Joeware there is CPAU - Create Process as User which is a freeware tool that uses a proprietary encryption process that Joe describes as using "strong obfuscation."

Quimeras uses the Microsoft CryptoApi for it's TqcRunAs product. It is a commercial product, but it reasonably priced for what it does.

Top
#149401 - 2005-10-06 04:34 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
thoes require an exe to interpret the script they generate, thoes exe's are not allowed on my network
Top
#149402 - 2005-10-06 04:45 PM Re: runas with quotes in the command??
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Then you should seriously consider running your script as a GPO script and have it install the software under the system context.
Top
#149403 - 2005-10-06 04:51 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
thanks anyway guys
Top
#149404 - 2005-10-06 05:05 PM Re: runas with quotes in the command??
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
There are many topics about runas. All with the same conclussion: it doesn't work with Kix.

Try one of the taskscheduler UDF's....

http://www.kixhelp.com/udfs/udf/81888.htm
http://www.kixhelp.com/udfs/


Edited by Co (2005-10-06 05:08 PM)
_________________________
Co


Top
#149405 - 2005-10-06 05:28 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
that would be fine but i need the user to be able to run it when they need to
Top
#149406 - 2005-10-06 06:05 PM Re: runas with quotes in the command??
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
RunAs works with VBS.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149407 - 2005-10-06 08:40 PM Re: runas with quotes in the command??
matthewst Offline
Getting the hang of it

Registered: 2005-01-26
Posts: 89
GOT IT!!!!!!!!!!
tried vbs and with a lot of trial and error was able to get the following vbs script cut down to 11 lines and working, now i only have to encrypt it

THANKS TO EVERYONE HERE FOR YOU HELP

'Start of Script
'VBRUNAS.VBS
'v1.2 March 2001
'Jeffery Hicks
'jhicks@quilogy.com http://www.quilogy.com
'USAGE: cscript|wscript VBRUNAS.VBS Username Password Command
'DESC: A RUNAS replacement to take password at a command prompt.
'NOTES: This is meant to be used for local access. If you want to run a command
'across the network as another user, you must add the /NETONLY switch to the RUNAS
'command.

' *********************************************************************************
' * THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS *
' * NECESSARY TO MEET YOUR NEEDS. THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES, *
' * EXPRESS, IMPLIED OR OF ANY OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS. *
' * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB *
' * ENVIRONMENT. USE AT YOUR OWN RISK. *
' *********************************************************************************

On Error Resume Next
dim WshShell,oArgs,FSO

set oArgs=wscript.Arguments

if InStr(oArgs(0),"?")<>0 then
wscript.echo VBCRLF & "? HELP ?" & VBCRLF
Usage
end if

if oArgs.Count <3 then
wscript.echo VBCRLF & "! Usage Error !" & VBCRLF
Usage
end if

sUser=oArgs(0)
sPass=oArgs(1)&VBCRLF
sCmd=oArgs(2)

set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")

if FSO.FileExists(winpath) then
'wscript.echo winpath & " " & "verified"
else
wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work."
set WshShell=Nothing
set WshEnv=Nothing
set oArgs=Nothing
set FSO=Nothing
wscript.quit
end if

rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit

'************************
'* Usage Subroutine *
'************************
Sub Usage()
On Error Resume Next
msg="Usage: cscript|wscript vbrunas.vbs Username Password Command" & VBCRLF & VBCRLF & "You should use the full path where necessary and put long file names or commands" & VBCRLF & "with parameters in quotes" & VBCRLF & VBCRLF &"For example:" & VBCRLF &" cscript vbrunas.vbs quilogy\jhicks luckydog e:\scripts\admin.vbs" & VBCRLF & VBCRLF &" cscript vbrunas.vbs quilogy\jhicks luckydog " & CHR(34) &"e:\program files\scripts\admin.vbs 1stParameter 2ndParameter" & CHR(34)& VBCRLF & VBCRLF & VBCLRF & "cscript vbrunas.vbs /?|-? will display this message."

wscript.echo msg

wscript.quit

Top
#149408 - 2005-10-07 12:09 AM Re: runas with quotes in the command??
iffy Offline
Starting to like KiXtart

Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
Did you try escaping the " with a \ as explained in runas /? that I posted earlier. Just curious as to if that would have worked in your case.
Top
#149409 - 2005-10-08 04:39 PM Re: runas with quotes in the command??
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And now you just told all your users what the admin password is? Is that consistent with running a seure network?
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1782 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.074 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