By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,846 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,846 IT Pros & Developers. It's quick & easy.

Run .bat batch file from within HTML document

P: 2
Hello, I have searched for this answer and the posted solutions do not work for me or they are slightly different.

I have a USB flash drive that contains default.htm, medical.bat, and java folders/files

What I want to do is run medical.bat from within default.htm when the user clicks on a launch button or image. The medical.bat file contains parameters to run a java application that also resides on the USB flash drive. If I link the medical.bat file to an image via <a href> a dialog pops up asking to run or save, running brings up the command prompt for a second and then nothing happens. However, when I double click medical.bat the command prompt runs and stays open and the java application launches just fine.

This should be simple, but it is proving to be difficult
Mar 4 '08 #1
Share this Question
Share on Google+
2 Replies


P: 1
It sounds like your problem might be due to the use of relative paths in your .bat file.

When you double-click it in its folder, that's where it's running from, so any relative reference to your java file (\java\whatever.jar, as opposed to c:\java\whatever.jar) is correctly routed.

If you run it from a web browser, however, the browser downloads the .bat to a temp folder, then runs it from there. Once it runs, it looks for the java files, and can't find them (because they're not in the temp folder with it).

Not sure what the solution to that would be, since it doesn't sound like you're able to use absolute paths.
Mar 4 '08 #2

P: 2
It sounds like your problem might be due to the use of relative paths in your .bat file.

When you double-click it in its folder, that's where it's running from, so any relative reference to your java file (\java\whatever.jar, as opposed to c:\java\whatever.jar) is correctly routed.

If you run it from a web browser, however, the browser downloads the .bat to a temp folder, then runs it from there. Once it runs, it looks for the java files, and can't find them (because they're not in the temp folder with it).

Not sure what the solution to that would be, since it doesn't sound like you're able to use absolute paths.
Now it makes sense why it won't even work if I hard code the path of the medical.bat file to the "current" location of the USB drive. I did not know .bat files were copied to a temp folder - in my case, it defaults to my desktop. I was able to capture a screen shot of the command prompt as it flashed up and disappered, and it was looking for the files on the desktop. It works to click the .bat file in the html file when the java folders are on the desktop. Now it is figuring out how to use relative paths. Any thoughts?
Mar 6 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.