running .bat files not working for me in MS any longer

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

running .bat files not working for me in MS any longer

Post by montanan » Sat Dec 22, 2012 2:57 pm

I was able to run my .bat files previously but have recently upgraded to 13.2.4. I am on a Win7 64bit PC.

My bat file has the following code in it.

Code: Select all

@ECHO OFF
ECHO This text goes to Standard Output
ECHO This text goes to Standard Error 1>&2
ECHO This text goes to the Console>CON
When I run it from the command line, I run it as...

c:\test\test.bat > c:\test\testlog.txt 2> c:\test\testerrors.txt

... and the third line goes to the console, the second line is written to the file called c:\test\testerrors.txt and the first line is written to c:\test\testlog.txt

When I try to run this from Macro Scheduler, my code is...

Code: Select all

RunProgram>cmd /c c:\test\test.bat > c:\test\testlog.txt >2 c:\test\testerrors.txt
... and I see a CMD window flash briefly but nothing seems to happen and the two files (c:\test\testlog.txt and c:\test\testerrors.txt) are not written

I have tried various combinations of RP_ADMIN, turning off 64bit redirection, etc. but I cannot get things to work. I was able to run batch files in my prior version 13 install of Macro Scheduler so this is puzzling.

I would appreciate any and all suggestions on what next to try.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Dec 22, 2012 4:37 pm

Change the "cmd /c" to "cmd /k" so the command window stays open. Then fix your typo where you reversed the order of "2>".

Is this closer to what you're looking for?

Code: Select all

RunProgram>cmd /k c:\test\test.bat > c:\test\testlog.txt 2> c:\test\testerrors.txt

montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Post by montanan » Sat Dec 22, 2012 5:17 pm

Thank you!

The /k argument is really helpful.

With my typo fixed, my test program is working very well now.

Now, onward to test some additional .bat files. It is so much nice to run them from within Macro Scheduler than any other way.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Dec 22, 2012 7:33 pm

I have a follow-up question which may also affect what montanan is doing. On win7/64 something run directly from the command prompt uses the 64 bit version of cmd.exe. I think I'm correct in stating that even the latest Macro Scheduler is a 32 bit program, and in that case does RunProgram>cmd run the 32 bit cmd.exe, or the 64 bit cmd.exe?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sat Dec 22, 2012 9:25 pm

OK, figured out how to answer my own question. RunProgram>cmd will run the 32 bit version of cmd.exe on a Win 7/64 system.

montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Post by montanan » Sat Dec 22, 2012 11:25 pm

Thanks for chiming in on this, Me_again.

I spent some more time troubleshooting my environment today -- got it working fine again -- so wanted to pass this along in case it may be helpful to others at some point.

I could run a simple .bat file after the fix above, but all of my complex .bat files which were running fine a week ago when called from Macro Scheduler were still not working. I kept getting the following error...

.bat is not recognized as an internal or external command

... so I searched on it. That led me to an article...

http://blade.nagaokaut.ac.jp/cgi-bin/sc ... talk/51756

... which indicated that this could be related to an issue in my PATH statement. I uninstalled the only two programs I had installed or updated in the last week, one of them being my upgrade to the latest Macro Scheduler. I recalled that I had (I think for the first time) chosen to associate Macro scheduler with a few different file types during the install. I uninstalled both programs and reinstalled only Macro Scheduler -- this time not associating it with any other Windows file types. My issue went away. I don't know definitively that my upgrade of Macro Scheduler last week was the source of the issue, but thought I'd pass this along in case other run into similar issues related to PATH.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts