Batch File help please

nzepeda

Board Regular
Joined
Nov 11, 2010
Messages
58
Anyone good with Batch files?

If so I am having a small issue with a very basic batch file I wrote.
Basically all it does is startup a program named load.exe

This is exactly how it looks.
Code:
PATH="C:\Display"
load.exe

Now the issue I am having is that this program uses a jpg file which is in the same directory. It uses it as a graphic. Now when I run this batch file the program runs, but I get an error of "Can not load jpg" in an error mesaage, I can click Ok and the program continues to run, without the graphic. Normally to run this I double click it and it runs fine. Is there something that I am missing?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
i suspect you are calling the batch file when the current directory is not equal to c:\display

and probably load.exe looks in the current directory for the graphic file. that is why it cannot find the file, because the current directory is not where the graphic file is.

you can issue the sequence of commands in your batch file (path variable setting is not needed in this case)

C:
CD display
load.exe

then you will see the graphic.

however, you will change directories into C:\display using this method.

if you don't want that, there are methods to save the current drive and directory into environment variables before issuing the C: and cd commands, so you can change back to the starting directory after load.exe completes.

note that your method of changing the path environment variable means that commands you enter in the DOS window after your batch file executes will likely not be found - the path tells where to look for programs if they do not exist in the current directory.

so you must figure out exactly what you want to do - batch files (called command scripts too) were used long before windows was invented, and as such can be very powerful, but require a knowledge base of their own if you want to get fancy.

Chaz
 
Upvote 0
by the way, i forgot to note a little known behavior:

no commands issued after the load.exe command would be executed (if they exist).

to keep the batch file in control, you must have a command of the form:

call load.exe

or

cmd.exe -k load.exe

these start a new command interpreter which runs the program, and returns control to the batch file after it exits. otherwise, the current command interpreter quits after load.exe runs, and no later commands are processed.

Chaz
 
Upvote 0
Thanks for the replies.

After I posted this I forgot to get back on here for any advise posted. I was able to get it to work by:
1. Coping the graphic to the folder where the batch file was located (which I see from your first post is what you suspected)
2. Changed the way I called load.exe, changed the line to "start /d "c:\display" load.exe". I was having an issue with having the rest of the code run after what I had in there at first.

Thank you for your advice and knowledge.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top