Sign in to follow this  
Followers 0
van_renier

RunAsSet and ShellExecute

5 posts in this topic

Autoit v3.2.4.9

Windows 2000 and 2003

In the Docs, ShellExecute references RunAsSet in the "Related" functions section. RunAsSet() states, though, it only works for the Run and RunWait functions.

Is RunAsSet supposed to work for ShellExecute and ShellExecuteWait, too?

I need to have AutoIt execute a program using a specific username/password, which I'm using RunAsSet to accomplish. The program, however, requires arguments/parameters to be passed upon execution which gives Run/RunWait problems;

$UserID="ScriptUserID"
$Domain=@COMPUTERNAME
$UserPW="password"
$Execute = "D:\MyFolder\MyProgram.exe"
$Arguments = "-u 2 -v Yes -l 9"
$WorkingDir = "D:\MyFolder\"
RunAsSet( $UserID, $Domain, $UserPW)

; ShellExecute doesn't make use of RunAsSet, making this ineffective for my needs.
ShellExecute ( $Execute, $Arguments, $WorkingDir, "open" )

; Run can't handle executing the EXE with arguments;
Run( $Execute & " " & $Arguments, $WorkingDir )

; This next one works, but requires an empty CMD Prompt window as the EXEs parent process.
; Killing/closing the empty CMD prompt window kills the required child process/EXE.
Run( @ComSpec & " /C " $Execute & " " & $Arguments, $WorkingDir )

; I've also tried this but it didn't work for me either (can't recall the details of why ATM)
Run( @ComSpec & " /C start " $Execute & " " & $Arguments, $WorkingDir )

Does anyone have any ideas how can I pass arguments to an EXE at execution AND make use of RunAsSet()?

(I would prefer to keep this entirely AutoIt and not use any external/3rdparty utilities like psexec.exe, etc...)

Thanks for your time, effort and thoughts!

Van Renier

Share this post


Link to post
Share on other sites



Autoit v3.2.4.9

Windows 2000 and 2003

In the Docs, ShellExecute references RunAsSet in the "Related" functions section. RunAsSet() states, though, it only works for the Run and RunWait functions.

Is RunAsSet supposed to work for ShellExecute and ShellExecuteWait, too?

I need to have AutoIt execute a program using a specific username/password, which I'm using RunAsSet to accomplish. The program, however, requires arguments/parameters to be passed upon execution which gives Run/RunWait problems;

$UserID="ScriptUserID"
$Domain=@COMPUTERNAME
$UserPW="password"
$Execute = "D:\MyFolder\MyProgram.exe"
$Arguments = "-u 2 -v Yes -l 9"
$WorkingDir = "D:\MyFolder\"
RunAsSet( $UserID, $Domain, $UserPW)

; ShellExecute doesn't make use of RunAsSet, making this ineffective for my needs.
ShellExecute ( $Execute, $Arguments, $WorkingDir, "open" )

; Run can't handle executing the EXE with arguments;
Run( $Execute & " " & $Arguments, $WorkingDir )

; This next one works, but requires an empty CMD Prompt window as the EXEs parent process.
; Killing/closing the empty CMD prompt window kills the required child process/EXE.
Run( @ComSpec & " /C " $Execute & " " & $Arguments, $WorkingDir )

; I've also tried this but it didn't work for me either (can't recall the details of why ATM)
Run( @ComSpec & " /C start " $Execute & " " & $Arguments, $WorkingDir )

Does anyone have any ideas how can I pass arguments to an EXE at execution AND make use of RunAsSet()?

(I would prefer to keep this entirely AutoIt and not use any external/3rdparty utilities like psexec.exe, etc...)

Thanks for your time, effort and thoughts!

Van Renier

Try this:

; This next one works, but requires an empty CMD Prompt window as the EXEs parent process.
; Killing/closing the empty CMD prompt window kills the required child process/EXE.
Run( @ComSpec & " /C " $Execute & " " & $Arguments, $WorkingDir, @SW_HIDE )

Share this post


Link to post
Share on other sites

...In the Docs, ShellExecute references RunAsSet in the "Related" functions section. RunAsSet() states, though, it only works for the Run and RunWait functions....

Hmmm, we'll have to look into that.

Run should run most anything - but I don't see any problems with your syntax at first glance.... got to go for now.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Try this:

; This next one works, but requires an empty CMD Prompt window as the EXEs parent process.
; Killing/closing the empty CMD prompt window kills the required child process/EXE.
Run( @ComSpec & " /C " $Execute & " " & $Arguments, $WorkingDir, @SW_HIDE )
Thanks for your suggestion, SWG, but I already have tried using the "@SW_HID" flag (although omitted in my syntax samples). The intent is to have the EXE executed without having a parent CMD.EXE process, similar to how ShellExecute handles it. Having a hidden CMD prompt window is just as undesirable as the visible empty one; If someone opens task manager and sees CMD.EXE in the process list, but no visible windows, I don't them to arbitrarily close it.

Any other ideas?

Van

Share this post


Link to post
Share on other sites

Is RunAsSet supposed to work for ShellExecute and ShellExecuteWait, too?

no. Re-Run the whole script with admin (or whatever user you need) privileges. See here: http://www.autoitscript.com/forum/index.ph...st&p=339615.


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0