Sign in to follow this  
Followers 0
selder

Run a BAT file from a network source

13 posts in this topic

I have an AutoIt script that runs a BAT file directly from a network source. This BAT file is a bat file that another team changes when they see fit, and it needs administrative privileges on the local computer.

My AutoIt script is on another network source.

The line where I call the bat file is the following:

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat")

My script works wonderfully when it is on a local harddrive (e.g. C:\ ), but not when I run it from a mapped network drive.

Any ideas?

Share this post


Link to post
Share on other sites



I have an AutoIt script that runs a BAT file directly from a network source. This BAT file is a bat file that another team changes when they see fit, and it needs administrative privileges on the local computer.

My AutoIt script is on another network source.

The line where I call the bat file is the following:

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat")

My script works wonderfully when it is on a local harddrive (e.g. C:\ ), but not when I run it from a mapped network drive.

Any ideas?

I have the same problem. Eager to get the answer...

Share this post


Link to post
Share on other sites

Did you try using RunAsSet?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I have an AutoIt script that runs a BAT file directly from a network source. This BAT file is a bat file that another team changes when they see fit, and it needs administrative privileges on the local computer.

My AutoIt script is on another network source.

The line where I call the bat file is the following:

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat")

My script works wonderfully when it is on a local harddrive (e.g. C:\ ), but not when I run it from a mapped network drive.

Any ideas?

Your example is running it from a UNC, not a mapped drive letter. Did you try mapping it first?

$MapDrv = DriveMapAdd("*", "\\server\Sap")
If @error = 0 Then
    RunWait(@ComSpec & ' /c ' & $MapDrv & '\SapLogon_ChangeSystems.bat')
Else
    MsgBox(16, "Error", "Error mapping drive to \\server\Sap")
EndIf

:)

Edit: Didn't like the error handling I had for DriveMapAdd.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Yes, I am using a RunAsSet() in that script, and there is no problem accesing the network shares (I'm using a domain admin account with generated password of about 50 characters.

Anyway, I tried mapping the network share, but that doesn't solve the problem.

Running the compiled AutoIt exe from a network share doesn't work. Copying that same exe locally (C:\ ) works just fine. I just don't understand why it would work locally and not on a network source.

Share this post


Link to post
Share on other sites

Same thing here......Did you ever resolve?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Well i dont know how many Stuff is written in that .bat file.

Maybe you try putting your stuff completely into autoit like this:

#include <Process.au3>
_RunDOS("DOS-Command here")
_RunDOS("DOS-Command here")
_RunDOS("DOS-Command here")

I managed my bat files like this, working like a charm.

I compiled them, and everytime i add a new Workstation to my Network, i just run my exe.

Hope this helps you a bit.

Edited by notorius

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Try adding the working directory.

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat", "\\server\Sap")

Edited by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Try

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat", @WindowsDir)

I have an AutoIt script that runs a BAT file directly from a network source. This BAT file is a bat file that another team changes when they see fit, and it needs administrative privileges on the local computer.

My AutoIt script is on another network source.

The line where I call the bat file is the following:

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat")

My script works wonderfully when it is on a local harddrive (e.g. C:\ ), but not when I run it from a mapped network drive.

Any ideas?

Share this post


Link to post
Share on other sites

Try

RunWait ( @COMSPEC & " /c \\server\Sap\SapLogon_ChangeSystems.bat", @WindowsDir)

Also, you could try to change to a .CMD extension......


Everseeker

Share this post


Link to post
Share on other sites

Hi.

Wrap your UNC addressed batch file into a locally started one.

Use "pushd" to temporarily assign a network drive letter to the UNC path of your batch.

Then run it

use "popd" to remove the temp mapping finally.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Thanks all, adding that working directory at the end of the code did the trick!

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