Sign in to follow this  
Followers 0
dirtymafia

Running Program With Unc Path

23 posts in this topic

#1 ·  Posted (edited)

I'm trying to run a w32 exe file off a UNC path. I have the following:

If @OSTYPE <> "WIN32_NT" Then Exit

RunAsSet("admin",@computername,"password")

run("\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2")

RunAsSet()

I get the following error when I try to run it:

Line 0 (File c:\documents and settings\limited\desktop\autopatch.exe"):
run("\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2"

Error: Unable to execute the external program.

The system cannot find the path specified.

However, that exact run command will work from cmd prompt / batch file / start...Run. What am I missing?

Edited by dirtymafia

Share this post


Link to post
Share on other sites



To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

Try this. Maybe it will help.


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

I'm trying to run a w32 exe file off a UNC path. I have the following:

If @OSTYPE <> "WIN32_NT" Then Exit

RunAsSet("admin",@computername,"password")

run("\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2")

RunAsSet()

I get the following error when I try to run it:

Line 0 (File c:\documents and settings\limited\desktop\autopatch.exe"):
run("\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2"

Error: Unable to execute the external program.

The system cannot find the path specified.

However, that exact run command will work from cmd prompt / batch file / start...Run. What am I missing?

This is a question which is asked many times...

It is very likely that the RunAS credentials (being a local account for the PC) doesn't have any rigths on the target server ......


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

Try this. Maybe it will help.

I've tried that before, and I just tried it again with your command right there and I get:

Run-time error '5':

Invalid procedure call or argument

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This is a question which is asked many times...

It is very likely that the RunAS credentials (being a local account for the PC) doesn't have any rigths on the target server ......

The rights are fine. I've copied notepad.exe from my computer put it on the server that I'm trying to access and can run it fine, its when I go to use the command specified I get a problem.

I can run everything just fine in a batch file. I know what I'm going to hear next is "well then call the batch file from the autoit script". Well to put it simply I do not want to do that unless it is the only way.

EDIT:

I just tried something new. I used just "\\max01\admin\autopatcher\autopatcher.exe" without the command line arguments and it just ran perfectly, but as soon as I try to pass the cmd line arguments I get the problem.

Edited by dirtymafia

Share this post


Link to post
Share on other sites

Here's what I use. Maybe this will help.

$InstallFolder = "\\max01\admin\autopatcher"

Run($InstallFolder & "\autopatcher.exe /noeula /unattend:t2", $InstallFolder, @SW_MAXIMIZE)

Generally when I get this message, it's needing the Working Directory path as well.


Roger O."When people show you who they are, believe them.” --Mark Twain

Share this post


Link to post
Share on other sites

The rights are fine. I've copied notepad.exe from my computer put it on the server that I'm trying to access and can run it fine, its when I go to use the command specified I get a problem.

I can run everything just fine in a batch file. I know what I'm going to hear next is "well then call the batch file from the autoit script". Well to put it simply I do not want to do that unless it is the only way.

So user Admin defined on the PC has read access to the \\max01 server share ?

Or do you mean the user account that runs the script ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Here's what I use. Maybe this will help.

$InstallFolder = "\\max01\admin\autopatcher"

Run($InstallFolder & "\autopatcher.exe /noeula /unattend:t2", $InstallFolder, @SW_MAXIMIZE)

Generally when I get this message, it's needing the Working Directory path as well.

I still get the run-time error '5' with that.

Share this post


Link to post
Share on other sites

So user Admin defined on the PC has read access to the \\max01 server share ?

Or do you mean the user account that runs the script ?

Heres the setup:

User account (person running exe) is 'limited user' in XP and does not have rights to the share.

Admin has both rights to share and administrator in XP.

Share this post


Link to post
Share on other sites

When I'm running:

$InstallFolder = "\\max01\admin\autopatcher"
Run($InstallFolder & "\autopatcher.exe /noeula /unattend:t2", $InstallFolder, @SW_MAXIMIZE)

It still error's out with Run-time error 5 but if I'm look at task manager process' i see Autopatcher.exe pop up, but as soon as I hit OK on the run-time error window it closes autopatcher.exe

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I still get the run-time error '5' with that.

Then try this:

$USERNAME="administrator" ; domain administrator account name

$PASSWORD = "administrator_password_here" ; domain administrator account password

$Domain = "your_domain_here" ; i.e. company.local

$InstallFolder = "\\max01\admin\autopatcher"

;Increase Priveledges to Administrator on local system for installing this application

RunAsSet($USERNAME, $Domain , $PASSWORD)

Run($InstallFolder & "\autopatcher.exe /noeula /unattend:t2", $InstallFolder, @SW_MAXIMIZE)

;Resets increased priveledges to standard user

RunAsSet()

Edited by rogerd2u

Roger O."When people show you who they are, believe them.” --Mark Twain

Share this post


Link to post
Share on other sites

Then try this:

$USERNAME="administrator" ; domain administrator account name

$PASSWORD = "administrator_password_here" ; domain administrator account password

$Domain = "your_domain_here" ; i.e. company.local

$InstallFolder = "\\max01\admin\autopatcher"

;Increase Priveledges to Administrator on local system for installing this application

RunAsSet($USERNAME, $Domain , $PASSWORD)

Run($InstallFolder & "\autopatcher.exe /noeula /unattend:t2", $InstallFolder, @SW_MAXIMIZE)

;Resets increased priveledges to standard user

RunAsSet()

I wasn't sure what that really changed, besides putting everything in a variable but I tried it anyway. Same run-time error.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Everything works great if I take off "/noeula /unattend:t2".

As soon as I put those arguments into the mix I start having the problem. I can call autopatcher.exe w/o the arguments all day long without a problem. I know the arguments are accurate.

Edited by dirtymafia

Share this post


Link to post
Share on other sites

I wasn't sure what that really changed, besides putting everything in a variable but I tried it anyway. Same run-time error.

Well, what it changes is (assuming you filled in the domain administrator variable information correctly), the script portion between "RunAsSet($USERNAME, $Domain , $PASSWORD)" and "RunAsSet()" will be ran with administrator priveledges.


Roger O."When people show you who they are, believe them.” --Mark Twain

Share this post


Link to post
Share on other sites

Ok, just found something out I was kind of overlooking.. The run-time error is coming from AutoPatcher.exe after it is being run not from the autoit script. So With the following command what else could be being sent to autopatcher.exe making it see something that isn't a valid argument??

Run(@ComSpec & " /c" & "\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2")

Share this post


Link to post
Share on other sites

I think you need to go back to using the Comspec idea. I've been writing a script to call multiple packages for the past 2 months, and so I've been in the same position, and this is the only thing I can find that will do the trick.

Try the following:

RunWait(@ComSpec & ' /c \\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2', "", @SW_HIDE)

Everything works great if I take off "/noeula /unattend:t2".

As soon as I put those arguments into the mix I start having the problem. I can call autopatcher.exe w/o the arguments all day long without a problem. I know the arguments are accurate.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ok, just found something out I was kind of overlooking.. The run-time error is coming from AutoPatcher.exe after it is being run not from the autoit script. So With the following command what else could be being sent to autopatcher.exe making it see something that isn't a valid argument??

Run(@ComSpec & " /c" & "\\max01\admin\autopatcher\autopatcher.exe /noeula /unattend:t2")
It looks like you have missed a space after the /c switch, and try it with the following separation between the executable and parameters (you may also have to add the working directory)

Run(@ComSpec & " /c " & "\\max01\admin\autopatcher\autopatcher.exe" & " /noeula /unattend:t2")
Edited by billmez

Share this post


Link to post
Share on other sites

It looks like you have missed a space after the /c switch, and try it with the following separation between the executable and parameters (you may also have to add the working directory)

Run(@ComSpec & " /c " & "\\max01\admin\autopatcher\autopatcher.exe" & " /noeula /unattend:t2")
It turns out that the EXE itself (the one being run from the AutoIt script) will only run from a mapped drive. Well to do this I have completly given up on trying to put everything in autoit line code (because im doing a RunAsSet a mapadd will not work because that will map as current user; shares are not available on a different set of credentials). Instead what I am doing is having the script create a batch file, runit with the correct credentials and then delete the batch file. I am using the pushd and popd commands in the batch file to map and un-map the unc path.

Actually the script is already done; I even have two versions of it. The first version(autopatch(builtin).au3) includes all the information (UNC path, command line arguments for the target EXE, and the executable name that is being targeted) the 2nd one(autopatch(cmdline).au3) lets you provide all of those through a command line argument when calling the script (when compiled)

I am also in the process (and nearly complete; only thing left is creating the "save as.." portion) of making a gui wizard that you can input the unc path, pick command line arguments, specify EXE name, and also specify credentials used to run it(the specified EXE) then when you hit the finish button it will create a temp .au3 file and then compile it. Then that EXE will act as autopatch(builtin).au3 version of the first script.

The only reason I am putting all this in the forum is so that if any would like this functionality you can contact me and I will send the wizard on after completion.

Share this post


Link to post
Share on other sites

Ok, got another question. I have it all working fine, with making the bat file, running it, and then deleting the temp bat file, however, I would really like this to all be in the program without having to write the batch file. Seems more professional and clean, as well as 1 less thing to go wrong, if I put it all in the program.

I have problems when I do something like this:

Run(@ComSpec & " /c" & "pushd \\max01\admin\autopatcher" & @crlf & "ap.exe /noeula /unattend:t2" & @crlf & "popd")

First problem is that my program needs to do a runwait on the ap.exe because the share can't be removed (popd) until after ap.exe is done running (program needs to access itself through the map). If I break up the commands into different Run(@comspec......) lines then line 1 (pushd) will work fine, but then when I call line 2 (ap.exe /noeula ...etc) it will not goto the mapped drive letter cmd prompt (like after you run pushd your cmd prmpt auto goes to the mapped drive letter) and I have no way of knowing what letter it will be because pushd uses last available. And then of course line 3 will not work correctly because popd will only work in the same command window as pushd was used (at least I think).

I can't think of an ingenious way to run this yet, which is why I'm asking for help. Hopefully I'm over looking over some logical way of doing this and you can point me in the right direction.

Share this post


Link to post
Share on other sites

try

$dir = @workingdir

FileChangeDir("\\max01\admin\autopatcher")

RunWait...

FileChangeDir($dir)

The ap.exe CAN NOT be ran from a UNC path. What I'm taking from what your reading is to just make the working directory that of the unc path and then running the cmd. This will not work. Also drivemapadd() will not work for me either because I need to do all of this in a RunAsSet. ...unlesss...........

Is there a way to call an in-built function (ie drivemapadd) from a Run(..) or Runwait(..) ?? This would cause the drivemapadd() to be called with the necessary RunAsSet credentials.

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