Jump to content

Run a BAT file from a network source


selder
 Share

Recommended Posts

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?

Link to comment
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...
Link to comment
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?

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
Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
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?

Link to comment
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!

Link to comment
Share on other sites

  • 2 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...