Running a "BAT file from MacroScheduler

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Kent Rukke
Newbie
Posts: 18
Joined: Fri Mar 19, 2004 4:59 pm
Location: Ephrata, Washington USA
Contact:

Running a "BAT file from MacroScheduler

Post by Kent Rukke » Tue Jul 13, 2004 9:25 pm

When I run a "BAT" file from MacroScheduler, I get a result of "0". The "BAT" file runs fine if it is run using Explorer. This doesn't happen on all of the "BAT" files I have. I don't understand.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jul 13, 2004 11:14 pm

Not sure how you are running the file, but I always use Run Program vs. ExecuteFile for batch files.

Usually looks something like this:
MidStr>%OS_VER%,1,2,OS
If>%OS%=95,WIN9X,NT

Label>WIN9X
Let>COMSPEC=Command.com
// Let>Set other WIN 95/98 conditions
Goto>Start

Label>NT
Let>COMSPEC=Cmd.exe
// Let>Set other WIN NT/2K/XP conditions
Goto>Start

Label>Start
...
...
Let>RP_WAIT=1
Run Program>%COMSPEC% /c c:\batch\batchfile.bat
Let>RP_WAIT=0
....
...
Label>End
A result code of 0 usually indicates that the system was out of memory, or the executable file was corrupt, or relocations were invalid.

If you are using ExecuteFile, I don't think that a Result code comes back in Macro Scheduler, so RP_RESULT-0 may be normal if using ExecuteFile vs. Run Program.
=============================
If the information above does not help, can you provide example of code calling the batch file, and perhaps also show the batch file contents, and ID the Operating System you are running this on.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Kent Rukke
Newbie
Posts: 18
Joined: Fri Mar 19, 2004 4:59 pm
Location: Ephrata, Washington USA
Contact:

Post by Kent Rukke » Wed Jul 14, 2004 4:16 pm

This is the "BAT" file

set PATH=c:\j2sdk1.4.1_02\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;Y:.;Z:.;

set classpath=c:\novell\ndk\ndssdk\java\lib\ldap.jar;

cd \
cd c:\eguide

java eGuide_Update > Err.log

ECHO Hi >>C:\eGuide\procdone.txt


This is the "script"
===============================================

Remark>This will run eGuide.bat
Let>subject= Weekly run of eGuide has started
Gosub>WriteToFile
Let>COMSPEC=Cmd.exe
Let>RP_WAIT=1
Run Program>%COMSPEC% /c C:\eGuide\eGuide.bat
Let>RP_WAIT=0
Let>subject= Weekly run of eGuide has finished
Gosub>WriteToFile
GoTo>EndOfScript

SRT>WriteToFile
DateStamp>m:\KRUKKE\BatchLog\BatchLog.txt,%subject%
End>WriteToFile

Label>EndOfScript


===============================================

This is used on Windows NT. The "BAT" file runs fine if you use Windows Explorer and double click on it. All directories exist.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jul 14, 2004 6:51 pm

I don't have access to an NT system right now, but everything looks good.
I get a result of "0".
I don't see you checking for an error code.
How is that error coming back to you? Can you add a line:
Let>RP_WAIT=1
Run Program>%COMSPEC% /c C:\eGuide\eGuide.bat
Let>RP_WAIT=0
MessageModal>Result code of batch file is %RP_RESULT%
What symptoms are you getting that indicate an error?

Do you have a copy of a log file?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Kent Rukke
Newbie
Posts: 18
Joined: Fri Mar 19, 2004 4:59 pm
Location: Ephrata, Washington USA
Contact:

Post by Kent Rukke » Mon Aug 02, 2004 4:20 pm

Hello:

It looks like the problem is when the "BAT" file is run using MacroScheduler, the old "DOS" command line limit of ~127 characters causes a problem, but using Windows Explorer, the limit is ignored. The "PATH" statement is over 130 characters.

surferdude

Post by surferdude » Tue Aug 03, 2004 3:36 am

Just a suggestion. I solved a similar problem with a program under w2k(not Macro Scheduler) that didn't like to run a .bat by setting up a shortcut to the .bat file (renamed it to something like domybat) and then the program was happy to run it as though it was a regular windows program.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 03, 2004 4:36 am

Some untested thoughts that come to mind........

I will have to do some digging, but I think you may be able to overcome the 128 character length by changing the environment variable in config.sys .....

shell=c:\windows\command.com c: /e:8192 /p

-----------------
I don't believe that NT uses config.sys, so you may have to do something in the registry instead,
HCU\Environment
HLMS\ControlSet001\Control\Session Manager\Environment

-----------------
Or pass a set command in a batch file, something like this:

Set<c:\batch\envNT.txt
where envNT.txt contains the shell line above.

---------------------------
Increasing the /e:size value maynot overcome the 127 character limit, it is just a consideration. I am sure someone else can correct this as needed.

---------------------------
Or does splitting the PATH command help to overcome the limit? Like:
PATH=c:\j2sdk1.4.1_02\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem
PATH=%PATH%;C:\WINNT\system32\nls;C:\WINNT\system32\nls\ENGLISH;Y:.;Z:.;

I guess it 's at least good that you found the cause. Thanks for the feedback Kent.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Kent Rukke
Newbie
Posts: 18
Joined: Fri Mar 19, 2004 4:59 pm
Location: Ephrata, Washington USA
Contact:

Post by Kent Rukke » Tue Aug 03, 2004 12:58 pm

Thanks for the information Bob. The problem was resolved by splitting the "PATH" into multiple commands. Thanks again for your ideas.

Ecoli

Also having the same problem

Post by Ecoli » Sat Aug 21, 2004 4:11 am

Hi all,

I have been having a similar problem. I was running Windows 98. In order to get the Run Program to work on a BAT file, I had to make a shortcut (a PIF file). For some reason, I never could get the Run Progam to work with the BAT file directly. The path was short and correct, and the BAT file would run when double clicked. I used the shortcut method as a workaround.

I recently went to XP Pro, and I can't get it to work at all now. The BAT file still runs fine when double clicked. I am way under the 128 character limit. Path and names are correct. I can't even get my shortcut trick to work this time with XP. Does anybody have any ideas? RP_RESULT gives me a 0. I don't understand why I would get this, but the file runs fine when run manually. Any of you gurus out there have any ideas? Thanks in advance.

Eric

Ecoli

Nevermind

Post by Ecoli » Sat Aug 21, 2004 9:28 pm

Nevermind... I got it working.

I had to use the Change Directory statement first to change the directory to where my batch file was actually residing, the use the Run Program statement. After I did that, everything ran like clockwork.

Thanks,
Eric

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Aug 21, 2004 9:43 pm

Thanks for feedback.....good to know is it not OS related issue.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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