Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gunji767
Contributor
Contributor

How to call a bat files by using jscript in qlikview?

Dear All,

I am trying to call bat files using macros with the help of j script. But while trying to run the program exception is happens. Below is the jscript code i have used in macros.

<html>

<head>

<title>Run Exe or Bat files from HTA by Hackoo</title>

<HTA:APPLICATION

  APPLICATIONNAME="Run Exe or Bat files from HTA by Hackoo"

  ID="MyHTMLapplication"

  VERSION="1.0"/>

</head>

<script>

function RunExe(){

    var shell = new ActiveXObject("WScript.Shell");

    var path = '"D:/run.bat"';

    shell.run(path,1,false);

}

</script>

<input style="width: 170px; height:23px; color: white; background-color: #203040;

font-family:Book Antiqua;" type="button" Value="bat" onClick="RunExe();"

</html>

14 Replies
Anil_Babu_Samineni

May be run it as this?

<script language="JavaScript" type="text/javascript">
  MyObject = new ActiveXObject("WScript.Shell")
  function Runbat()
  {
  MyObject.Run("\"C:\\Private\\Anil_ITPL\\Desktop\\welcometest.bat\"");
  }
  </script>

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
gunji767
Contributor
Contributor
Author

Hi Anil,

I have run this script, but it shoes syntax error like below

Anil_Babu_Samineni

You can not write Script Tags over Module. May be this?

function Runbat() {

  MyObject = new ActiveXObject("WScript.Shell")

  {

  MyObject.Run("\"C:\\Private\\Anil_ITPL\\Desktop\\welcometest.bat\"");

  }

}

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
gunji767
Contributor
Contributor
Author

Dear All,

If possible, to call bat files through VBScript  or any another ways please update me.

Regards

Hareesh.

gunji767
Contributor
Contributor
Author

Dear Anil,

Some exception is happens please have a look.

Regards,

Hareesh.

PrashantSangle

Hi,

If you want to execute only bat file

then you can use below command.

EXECUTE  D:\temp\test.bat;

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anil_Babu_Samineni

For me, This is okay

Capture.PNG

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
gunji767
Contributor
Contributor
Author

Hi Prasanth,

I am run this code by using macros. It is not working properly please have a look.

Regards,

Hareesh.

gunji767
Contributor
Contributor
Author

Hi,

code is working, but while trying to execute exception is happens like 'Automation server can't create object'