Page 5 of 5 <12345
Topic Options
#187037 - 2008-04-17 07:16 PM Re: RUNNAS - Tokenized Runas Utility [Re: Rixter]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Not sure what you mean when you say "XCOPY.TOK is the version that comes with Vista.". TOK files are generated by runnas.
Top
#187047 - 2008-04-17 09:21 PM Re: RUNNAS - Tokenized Runas Utility [Re: Shawn]
Rixter Offline
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
#187049 - 2008-04-17 09:25 PM Re: RUNNAS - Tokenized Runas Utility [Re: Rixter]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You cannot just tokenize xcopy.exe. You need to create a script that uses xcopy with the username and pw and all other stuff you need and tokenize the script.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#187052 - 2008-04-17 10:11 PM Re: RUNNAS - Tokenized Runas Utility [Re: Mart]
Rixter Offline
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
#187053 - 2008-04-17 10:23 PM Re: RUNNAS - Tokenized Runas Utility [Re: Rixter]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Copying kix with an admin script would be one way. Collect all computer names that should get kix and run a copy job from one admin workstation.
An other way it to create a folder on lets say c:\ on each machine with a startup script and set permissions on it with xcacls or the Vista equivalent (if there is a special vista version). Then you can use a logon script to copy stuff to that folder.
A third way would be to run kix32 from the server and not from the local workstation. Something like \\domain\somefoldershere\sysvol\kix32.exe \\domain\somefoldershere\script.kix.

We have the second option in place for some generic home made apps and other stuff. The third is the one I use to kick off my logon script. This way you have only one place to worry about when upgrading to a newer version of kixtart.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#190588 - 2008-11-15 02:15 AM Re: RUNNAS - Tokenized Runas Utility [Re: Shawn]
JJ1 Offline
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) \:\( :
 Code:
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
#190589 - 2008-11-15 02:22 AM Re: RUNNAS - Tokenized Runas Utility [Re: JJ1]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
May or may not have anything to do with your question, but what/where is RunEx?
Top
#190596 - 2008-11-15 07:20 PM Re: RUNNAS - Tokenized Runas Utility [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sounds like my old UDF.
_________________________
!

download KiXnet

Top
#190597 - 2008-11-15 07:21 PM Re: RUNNAS - Tokenized Runas Utility [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=83752
Top
#190626 - 2008-11-17 07:18 PM Re: RUNNAS - Tokenized Runas Utility [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
A Shell out to the program should be hidden using the CMD redirects
Top
#190632 - 2008-11-18 11:34 AM Re: RUNNAS - Tokenized Runas Utility [Re: NTDOC]
JJ1 Offline
Just in Town

Registered: 2008-11-15
Posts: 4
 Originally Posted By: NTDOC
A Shell out to the program should be hidden using the CMD redirects

Mmm, ok this works for this case:
 Code:
runas('%windir%\system32\cacls.exe %windir%\BGInfo.bmp /E /C /G "Users":F' > nul,1,0)

but not for this:
 Code:
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 Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Might this help?
http://esupport.trendmicro.com/support/viewxml.do?ContentID=1034748

Top
#190635 - 2008-11-18 04:07 PM Re: RUNNAS - Tokenized Runas Utility [Re: Allen]
JJ1 Offline
Just in Town

Registered: 2008-11-15
Posts: 4
 Originally Posted By: Allen

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
#190673 - 2008-11-19 09:08 PM Re: RUNNAS - Tokenized Runas Utility [Re: JJ1]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
To hide a console application you need to use and shell to CMD.EXE which supports the redirects, not the application.
Top
#190677 - 2008-11-20 12:06 AM Re: RUNNAS - Tokenized Runas Utility [Re: NTDOC]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Yeah... but then the cmd shell pops up instead. I think he was looking for completely hidden/silent.
Top
#190679 - 2008-11-20 02:40 AM Re: RUNNAS - Tokenized Runas Utility [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
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
 Code:
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 Offline
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)?

 Code:
$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......
 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 Offline
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
#213676 - 2019-04-29 08:02 PM Re: RUNNAS - Tokenized Runas Utility [Re: Shawn]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Imagine, 2019 and I thought I remembered runnas.. let's see if it still runs ;).
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#213678 - 2019-05-03 08:28 PM Re: RUNNAS - Tokenized Runas Utility [Re: Björn]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
It should run. Some new stuff in Windows 10 but basics should work I would think.

Let us know what you find, please.

Top
Page 5 of 5 <12345


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

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

Generated in 0.038 seconds in which 0.013 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