0

I have included the bat file path in anchor tag like this

<a href='pdfs1255601585.bat'>Execute batch file</a> But its showing some security warning, before executing the bat file.. Is it possible to bypass that warning to run.. Orelse, is there any other way to run the bat file through javascript

Thanks,
Praveen J

6 Answers 6

1

Can you imagine the chaos if this were possible? Visit a page and erase your harddrive.

Although there are applications where this would be handy, by design it was decided against as the security threat is massive.

You will not be able to do this simply though the use of JavaScript.

Sign up to request clarification or add additional context in comments.

1 Comment

Dear @Kyle Rozendo , I need a javascript command that Run a local batch file by onload page event. I know that ActiveXObject but it applies only for IE browser and it is not applicable for Chrome. Could you please help me?
1

Add the path to your batch file (i.e. C:\BAT_Files*) to your trusted sites in internet explorer. This will also modify the trusted sites used by Firefox and Google Chrome so you don't get the warnings on them either. The key is to use internet explorer's trusted site method.

Comments

0

You can't access file system using JavaScript. It is by design.

Tek-tips discussion on this

Comments

0

You can use ActiveX to do this. But it will be Internet Explorer specific.

Run Method (Windows Script Host)

1 Comment

is there any chance to focus without using ActiveX componenet?
0

You could use the code described here in order to run that batch. Bypassing the security warning - which is there with a reason - is kinda tricky. You could write an FireFox extension which would read the file to run from a particular page. Of course this extension needs to be installed with user interaction too. So no real bypassing at all...

Just for my curiousity; why do you want to do that?

ADDITION:

In php you could use the exec() command to achieve this.

1 Comment

Actually, i have a set of cmd line to execute-so i write those things in bat file and trying to run from here.. is there any other way through PHP.. Please guide me
0

You'd need some form of server-side language (such as PHP mentioned above) to do that. However generally it's considered bad practice and can open to you to any number of security risks if not undertaken carefully. Javascript can only access client-side information and files held on the server - it can't run executables (unless you include AJAX through a Server-side language running executables).

If you are intent on doing this, PHP exec() is the way to go, but you'd need to check your server configuration as I've heard of some companies (usually dealing in shared servers) disabling exec() to protect their other customers.

2 Comments

ianhales: how to enable the exec() and where to do that?
You'd need to speak to your hosting provider. It may be that they allow it - who is your host? They'll probably have it in an FAQ or something if it was blocked. If not then go with the link that @KB22 posted below.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.