tes5884 Posted July 13, 2012 Share Posted July 13, 2012 (edited) 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 July 13, 2012 by tes5884 www.tspitz.com Link to comment Share on other sites More sharing options...
BrewManNH Posted July 13, 2012 Share Posted July 13, 2012 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 GudeHow 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 More sharing options...
tes5884 Posted July 13, 2012 Author Share Posted July 13, 2012 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 www.tspitz.com Link to comment Share on other sites More sharing options...
IceBlackIce Posted July 13, 2012 Share Posted July 13, 2012 Just put a pause in your batch and see what error it gives...i believe its because its being run from a network share. Link to comment Share on other sites More sharing options...
tes5884 Posted July 13, 2012 Author Share Posted July 13, 2012 (edited) 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 July 13, 2012 by tes5884 www.tspitz.com Link to comment Share on other sites More sharing options...
IceBlackIce Posted July 13, 2012 Share Posted July 13, 2012 Try thisRegistry Keys for CMD:;Allow UNC paths at command prompt[HKEY_LOCAL_MACHINESOFTWAREMicrosoftCommand Processor]"DisableUNCCheck"=dword:00000001source:http://ss64.com/nt/cmd.html Link to comment Share on other sites More sharing options...
tes5884 Posted July 13, 2012 Author Share Posted July 13, 2012 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 www.tspitz.com Link to comment Share on other sites More sharing options...
BrewManNH Posted July 13, 2012 Share Posted July 13, 2012 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 GudeHow 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 More sharing options...
IceBlackIce Posted July 13, 2012 Share Posted July 13, 2012 If it works mapping the share but not using the unc path it must be related to the path itself, some environment variable that doesnt get passed, even more if you use another credential (admin privileges)...thats just my 0.02cents anyway. Link to comment Share on other sites More sharing options...
tes5884 Posted July 13, 2012 Author Share Posted July 13, 2012 I'm away from my PC until tomorrow. I will try your ideas tomorrow. Thank you all for your patience. www.tspitz.com Link to comment Share on other sites More sharing options...
tes5884 Posted July 16, 2012 Author Share Posted July 16, 2012 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 www.tspitz.com Link to comment Share on other sites More sharing options...
BrewManNH Posted July 16, 2012 Share Posted July 16, 2012 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 GudeHow 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 More sharing options...
tes5884 Posted July 16, 2012 Author Share Posted July 16, 2012 BrewManNH, Great idea! That's what I did, worked beautifully!! www.tspitz.com Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now