Jump to content

RunWait(".bat") on network share


Recommended Posts

Hi guys,

I have a FixWMI.bat file on a public share. When I double-click it works beautifully. However, when I execute it using:

RunWait("FixWMI.bat")

The command prompt flashes on the screen, and nothing happens.

If however I run the following, it does work.

FileCopy("FixWMI.bat", "C:")
RunWait("C:FixWMI.bat")
FileDelete("C:FixWMI.bat")

Any ideas?

Attached is the bat file, if anyone is interested.

Thanks

Edited by tes5884
Link to comment
Share on other sites

Where are you running the script from? You need to tell the script the full pathname and filename of the batch file when you run it, the way you wrote it, unless the script and the batch file are in the same directory it won't be able to find it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Where are you running the script from? You need to tell the script the full pathname and filename of the batch file when you run it, the way you wrote it, unless the script and the batch file are in the same directory it won't be able to find it.

It is in the same directory. I forgot to mention, we're running Windows 7 Enterprise/Professional.

Thanks

Link to comment
Share on other sites

Ok, it seems if I map the folder it works. If I just browse to the share, that's when it fails.

I guess I can have a script map a drive, then start my main script from the mapped drive.

Sounds a bit messy.

Any better ideas?

Thanks for the ideas so far guys!

Edited by tes5884
Link to comment
Share on other sites

To clarify, this is where I am at the moment;

Both network share and mapped drive, if I manually run/click the .bat it works. When I run it from the AutoIT script it just flashes on the screen, and nothing happens. (I'm running it using "RunWait").

  • I tried using pushd and popd in the bat file, which allows UNC paths, it didn't help.
  • I tried using the registry key posted by IceBlackIce, also didn't work.
  • I tried this on multiple machines, same problem.
  • I already have #requireadmin in the au3 script.

Leads to believe UNC isn't the issue.

Any more ideas are greatly appreciated.

Thanks all

Link to comment
Share on other sites

Try this and report back what you see in the console window.

Run(@Comspec & " /k FixWMI.bat")

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm back.

I tried using Run(@Comspec & " /k FixWMI.bat")

and got:

'MyServer01Software Distribution'

CMD.EXE was started with the above path as the current directory.

UNC paths are not supported. Defaulting to Windows directory.

The system cannot find the path specified.

Obviously, he isnt finding the FixWMI.bat in the windows directory, since its in the network share.

I could copy the bat file to the local machine, run it, then delete it.

I wish there was some cleaner way of doing it.

Thanks to IceBlackIce and BrewManNH for the help

Link to comment
Share on other sites

You can use AutoIt to map the drive, then run the batch file from the drive letter, then use AutoIt to unmap the drive.

DriveMapAdd to add the network drive, DriveMapDel to delete it when you're done. If you use DriveMapAdd with the asterisk for the drive letter, it will map to the first open drive letter and the return value is the drive letter it mapped it to, so that way you don't have to worry about what drives are already mapped which makes it more dynamic.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

  • Recently Browsing   0 members

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