Page 1 of 1
Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 16 Feb 2016 07:37
by mm@muellermario.de
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
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 16 Feb 2016 10:13
by foxidrive
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
Posted: 16 Feb 2016 15:14
by kwsiebert
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.
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 16 Feb 2016 23:54
by mm@muellermario.de
Hi all,
@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
Posted: 17 Feb 2016 00:46
by foxidrive
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
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 17 Feb 2016 02:06
by ShadowThief
mm@muellermario.de wrote:Can I investigate which working directory this script is running after calling via HTML?
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 17 Feb 2016 09:41
by kwsiebert
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.
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 17 Feb 2016 12:39
by julesverne
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.jpegBut I know jscript works with hta and javascript will too.
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 17 Feb 2016 21:22
by mm@muellermario.de
@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
Re: Call BAT-File (which uses as properties.csv ) from JAVASCript/HTML
Posted: 18 Feb 2016 01:36
by ShadowThief
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