Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Moderator: DosItHelp
-
- Posts: 12
- Joined: 20 Feb 2015 08:24
Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
HI all,
i wrote a BAT, which reads a customizing/properties CSV-File.
When I start the BAT via clicking in the windows explorer or via Windows-Button > R (un) enerything is fine.
Now I want to start the BAT via HTML.
The BAT echos an ERROR <Could not find "Customizing.csv">
Could anybody please explain, why this error occurs and how to avoid this?
Thanks
Regards
Mario
i wrote a BAT, which reads a customizing/properties CSV-File.
When I start the BAT via clicking in the windows explorer or via Windows-Button > R (un) enerything is fine.
Now I want to start the BAT via HTML.
The BAT echos an ERROR <Could not find "Customizing.csv">
Could anybody please explain, why this error occurs and how to avoid this?
Thanks
Regards
Mario
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
mm@muellermario.de wrote:Now I want to start the BAT via HTML.
I can't fathom how you are using HTML to launch a batch script.
For instance, a Web browser can't launch a batch script using plain HTML.
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
I believe an HTML document can execute a batch script through CGI.
If that is the case, what's probably happening is that the working directory is the one the HTML server is running from, and not the one the batch file is in. Have your batch file either use the full path to the CSV file, or preferably, explicitly change the current directory to where the script is located.
If that is the case, what's probably happening is that the working directory is the one the HTML server is running from, and not the one the batch file is in. Have your batch file either use the full path to the CSV file, or preferably, explicitly change the current directory to where the script is located.
-
- Posts: 12
- Joined: 20 Feb 2015 08:24
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Hi all,
@foxidrive: Yes, ist is possible to start.
example:
@kwsiebert
Good answer! Can I anyhow invstigate on which working directory this script is running after calling via HTML?
And yes: I used the absolute - and not the relative - path.
REgards
Mario
@foxidrive: Yes, ist is possible to start.
example:
Code: Select all
<head>
</head>
<body>
<input type="button" value="Name of the batch file" onclick="window.open('file:///G:/../.../THIS_IS_A_BAT_FILE.bat')"/>
</body>
@kwsiebert
Good answer! Can I anyhow invstigate on which working directory this script is running after calling via HTML?
And yes: I used the absolute - and not the relative - path.
REgards
Mario
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
mm@muellermario.de wrote:
@foxidrive: Yes, ist is possible to start.
example:Code: Select all
<head>
</head>
<body>
<input type="button" value="Name of the batch file" onclick="window.open('file:///G:/../.../THIS_IS_A_BAT_FILE.bat')"/>
</body>
All good, except it doesn't work in a standard web browser.
Code: Select all
echo @echo here^&pause>c:\test\FILE.bat
(
echo ^<head^>
echo ^</head^>
echo ^<body^>
echo ^<input type="button" value="Name of the batch file" onclick="window.open('file:///c:/test/FILE.bat')"/^>
echo ^</body^>
) > file.html
start file.html
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
mm@muellermario.de wrote:Can I investigate which working directory this script is running after calling via HTML?
Code: Select all
echo %cd%
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
foxidrive wrote:All good, except it doesn't work in a standard web browser.
Agreed. I tried it in the most current Firefox with no success. The file path isn't correctly escaped, for starters, but even when I fixed that, all it does is display the contents of the batch file in the browser window. Nothing is actually executed.
-
- Posts: 81
- Joined: 19 Nov 2013 00:41
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
kwsiebert wrote:foxidrive wrote:All good, except it doesn't work in a standard web browser.
Agreed. I tried it in the most current Firefox with no success. The file path isn't correctly escaped, for starters, but even when I fixed that, all it does is display the contents of the batch file in the browser window. Nothing is actually executed.
@kwsiebert if your goal is to run it locally on windows machines you should look into creating an hta. You won't be able to view it in firefox or chrome. What it does is use something installed on windows as mshta.
More information can be found here:
https://msdn.microsoft.com/en-us/librar ... 96(v=vs.85).aspx
Microsoft used to have a program called the hta helpomatic but it was taken down. It's kinda handy for those who don't know vbscript. It helps you builds hta files. I have it on my computer and the screenshot below is what it looks like.
http://img.brothersoft.com/screenshots/ ... 92692.jpeg
But I know jscript works with hta and javascript will too.
-
- Posts: 12
- Joined: 20 Feb 2015 08:24
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
@julesverne:
Your link is unfortunately not working.
https://msdn.microsoft.com/en-us/librar ... 96(v=vs.85).aspx
I would appreciate if you correct ist.
Regards
Mario
Your link is unfortunately not working.
https://msdn.microsoft.com/en-us/librar ... 96(v=vs.85).aspx
I would appreciate if you correct ist.
Regards
Mario
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Just add the string ).aspx to the URL that you go to when you click the link...
And if you're too lazy to do that, try this:
https://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx
And if you're too lazy to do that, try this:
https://msdn.microsoft.com/en-us/library/ms536496(v=vs.85).aspx