#187047 - 2008-04-17 09:21 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: Shawn]
|
Rixter
Fresh Scripter
Registered: 2005-03-15
Posts: 15
|
Shawn,
Sorry for the confusion. I ment that I'm using the version of XCOPY.EXE that comes with Vista.
I've created an XCOPY.TOK file using the syntax: (using a real acct and password) runnas /user:domainadmin "xcopy.exe" /pass:acctpwd /tok:xcopy.tok /logononly
Now I'm not at all sure how to take the XCOPY.TOK (which by the way is the version that comes with Vista) and actually incorporate it into my logon script.
|
Top
|
|
|
|
#187052 - 2008-04-17 10:11 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: Mart]
|
Rixter
Fresh Scripter
Registered: 2005-03-15
Posts: 15
|
Mart,
That makes more sense to me. The problem is, and maybe I'm going about this all wrong, is that in order to run the login script, which for us is a AD profile setting not a GPO, KIX32.EXE is copied locally to C:\. In my LOGIN.CMD file I have the following:
if exist %systemdrive%\kix32.exe goto logon copy %0\..\*.exe c:\ >nul :logon %systemdrive%\kix32.exe %0\..\login.kix if errorlevel 1 copy %0\..\*.exe %systemdrive%\ >nul exit
LOGIN.KIX works fine, it's just the copying of KIX32.EXE locally doesn't work without elevated priviledges for Vista. Do you think there's a better way of me doing this?
|
Top
|
|
|
|
#190588 - 2008-11-15 02:15 AM
Re: RUNNAS - Tokenized Runas Utility
[Re: Shawn]
|
JJ1
Just in Town
Registered: 2008-11-15
Posts: 4
|
It is possible to create a new parameter for the next release from RUNNAS? It would be great to have a add. parameter "/hide" to hide the window for the starting program / process.
The background is that I want start admin tasks, where the window is hidden or shown and the program waits or run async. --> the last point "/wait" is already exist "/wait Wait for the program to finish.".
I have try to realise it (hide the window) with the UDF RunEx or with some WSH code, but without any result . I think it works to hide the program runnas.exe but I can not hide the new starting process from the runnas utility .....
Here my current example code that should be "Pre-tokenizing", but the $HIDE=1 part is not working (hide and wait) :
Function runas($cmd,$hide,$wait)
Dim $User, $Pass, $runnas
$User = "DOMAIN\LOGONADMIN"
$Pass = "secret"
If Check_Server() = 0
IF $LOGGING WriteLog ("RunAs - Script not running on an Logonserver -> quit logon script - " + $Server) ENDIF
Quit
ENDIF
$runnas = @SCRIPTDIR + '\Tools\RunAs\runnas.exe'
IF $HIDE = 1
IF $WAIT = 1
RunEx($runnas, '/user:' + $User + ' "' + $cmd + '" /password:' + $Pass + ' /ENV /WAIT')
ELSE
RunEx($runnas, '/user:' + $User + ' "' + $cmd + '" /password:' + $Pass + ' /ENV')
ENDIF
ELSE
IF $WAIT = 1
SHELL $runnas + ' /user:' + $User + ' "' + $cmd + '" /password:' + $Pass + ' /ENV /WAIT'
ELSE
RUN $runnas + ' /user:' + $User + ' "' + $cmd + '" /password:' + $Pass + ' /ENV'
ENDIF
ENDIF
EndFunction
Or exist any other solution to hide the starting program? I have try to search the forum but I have not found a solution.
I think I can it also build it up with AutoIT but with this I miss the parameter "/ENV" .....
|
Top
|
|
|
|
#190597 - 2008-11-15 07:21 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: Lonkero]
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
Top
|
|
|
|
#190632 - 2008-11-18 11:34 AM
Re: RUNNAS - Tokenized Runas Utility
[Re: NTDOC]
|
JJ1
Just in Town
Registered: 2008-11-15
Posts: 4
|
A Shell out to the program should be hidden using the CMD redirects Mmm, ok this works for this case:
runas('%windir%\system32\cacls.exe %windir%\BGInfo.bmp /E /C /G "Users":F' > nul,1,0) but not for this:
runas("\\myserver\ofcscan\AutoPcc.exe > nul",1,0) Currently I use a own program with Autoit to hide and start the program, but want use in the future the runnas utility, so it would be nice the have an /HIDE switch ...., or have anybody an other idea to hide the window for an .exe file?
Edited by JJ1 (2008-11-18 11:35 AM)
|
Top
|
|
|
|
#190634 - 2008-11-18 03:03 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: JJ1]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
|
Top
|
|
|
|
#190635 - 2008-11-18 04:07 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: Allen]
|
JJ1
Just in Town
Registered: 2008-11-15
Posts: 4
|
Yes, thank you this helps for the AutoPcc.exe .....
BUT my wish with the "/HIDE" parameter is maybe also for application where it is not so easy to hide the output. I think it can be a usefull parameter...., and with it you (or better I ) must not search for other "tricks" to hide the output (?).
|
Top
|
|
|
|
#190679 - 2008-11-20 02:40 AM
Re: RUNNAS - Tokenized Runas Utility
[Re: Allen]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
|
No the CMD shell does not pop open. I use it all the time. The only reason you might see it is if you don't redirect it to nul or if it's just some odd behaving application that spews junk no matter what.
Here is an example
SHELL '%COMSPEC% /C "\\MYSERVER\SHARE2\WHOAMI.EXE" >NUL 2>NUL'
|
Top
|
|
|
|
#190696 - 2008-11-20 03:09 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: NTDOC]
|
JJ1
Just in Town
Registered: 2008-11-15
Posts: 4
|
This will be my last post in this thread maybe I should open a new post in the beginners section with the topic "What shell redirects are possible" . I have try a lot of combination with redirects but all without any good result.
My question is how can I hide any window from the starting program? --> when I start the program with the runnas.exe! I my example below it open every time the "CMD.EXE" window, of course I can hide the output in the CMD.EXE window, but not the window itself.
Maybe someone can show me in my small example how I can HIDE any output/window from my starting program (example 1 and 2)?
$rc = SetOption('NoVarsInStrings','ON')
$rc = SetOption('Explicit','ON')
; File _dir.cmd
;@ECHO OFF
;DIR %WINDIR% > %1\out.txt
; Example 1
runas(@SCRIPTDIR + '\_dir.cmd ' + @SCRIPTDIR)
; Example 2
;runas('%comspec% /c dir %WINDIR% > ' + @SCRIPTDIR + '\out.txt')
Function runas($cmd)
Dim $User, $Pass, $runnas
$User = "DOMAIN\USER"
$Pass = "PASSWORD"
$runnas = @SCRIPTDIR + '\runnas.exe'
RUN $runnas + ' /user:' + $User + ' "' + $cmd + '" /password:' + $Pass + ' /ENV /WAIT'
EndFunction
So I think it would be a good idea the have an extra switch, as example /HIDE, to hide any output/window from programs which are started with the runnas.exe.
In the meanwhile I have play with AutoIt and now I have an similar function with my "_RunAs.exe", is this possible with the runnas.exe in a similar way -> redirect or whatever?
As example what I mean my AutoIt code......
#NoTrayIcon
; PARAMETER
; _RunAs /user:USERNAME "command" /password:PASSWORD [/HIDE] [/WAIT]
If $CmdLine[0] > 2 Then
$Username = StringSplit ( $CmdLine[1], ":")
If $Username[1] = "/user" Then
$Username = $Username[2]
Else
_help()
EndIf
$Domain = StringSplit ( $Username, "\")
If @error Then
$Domain = @ComputerName
Else
$Username = $Domain[2]
$Domain = $Domain[1]
EndIf
$CMD = $CmdLine[2]
$Password = StringSplit ( $CmdLine[3], ":")
If $Password[1] = "/password" Then
$Password = $Password[2]
Else
_help()
EndIf
Else
_help()
EndIf
If $CmdLine[0] > 3 Then
If $CmdLine[4] = "/HIDE" Then
$Window = @SW_HIDE
Else
$Window = @SW_MAXIMIZE
EndIf
Else
$Window = @SW_MAXIMIZE
EndIf
If $CmdLine[0] < 5 Then
$WAIT = "/NOWAIT"
Else
$WAIT = $CmdLine[5]
EndIf
If $WAIT = "/WAIT" Then
RunAsWait($Username, $Domain, $Password, 0, $CMD, @TempDir,$Window)
Else
RunAs($Username, $Domain, $Password, 0, $CMD, @TempDir,$Window)
EndIf
exit 0
Func _help()
MsgBox(64,'Help','_RunAs.exe /user:USERNAME "command" /password:PASSWORD [/HIDE] [/WAIT]' & @CRLF & @CRLF & '<USERNAME> should be in form USER or DOMAIN\USER.')
Exit
EndFunc
Edited by JJ1 (2008-11-20 05:22 PM)
|
Top
|
|
|
|
#196042 - 2009-09-23 03:42 PM
Re: RUNNAS - Tokenized Runas Utility
[Re: JJ1]
|
Qnix
Just in Town
Registered: 2009-09-23
Posts: 1
Loc: a
|
Hi guys,
First of all many thanks for all the great tools. Secondly I want to launch the logon script in NT4 with admin rights and colon is not an allowed character so /user:user doesn't work for example. Could you perhaps add an alternative character as well? Space would do fine, to have runnas.exe abc.exe /user user /pass pass, instead of runnas.exe abc.exe /user:user /pass:pass? Or another allowed character for the logon script name string under NT4. It would save me a lot of headache!
Again, many thanks!
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 718 anonymous users online.
|
|
|