Running a "BAT file from MacroScheduler
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 18
- Joined: Fri Mar 19, 2004 4:59 pm
- Location: Ephrata, Washington USA
- Contact:
Running a "BAT file from MacroScheduler
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.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Not sure how you are running the file, but I always use Run Program vs. ExecuteFile for batch files.
Usually looks something like this:
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.
Usually looks something like this:
A result code of 0 usually indicates that the system was out of memory, or the executable file was corrupt, or relocations were invalid.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
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!
Bob
A humble man and PROUD of it!
-
- Newbie
- Posts: 18
- Joined: Fri Mar 19, 2004 4:59 pm
- Location: Ephrata, Washington USA
- Contact:
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.
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.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I don't have access to an NT system right now, but everything looks good.
How is that error coming back to you? Can you add a line:
Do you have a copy of a log file?
I don't see you checking for an error code.I get a result of "0".
How is that error coming back to you? Can you add a line:
What symptoms are you getting that indicate an error?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%
Do you have a copy of a log file?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Newbie
- Posts: 18
- Joined: Fri Mar 19, 2004 4:59 pm
- Location: Ephrata, Washington USA
- Contact:
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
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.
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!
Bob
A humble man and PROUD of it!
-
- Newbie
- Posts: 18
- Joined: Fri Mar 19, 2004 4:59 pm
- Location: Ephrata, Washington USA
- Contact:
Also having the same problem
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
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
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: