COMCreateObject – Opening an EXE File.

While working on COMCreateObject API provided by Siebel I noticed that with help of it we can communicate with Win 32 API provided by Windows which we usually do in VB.

So, when somebody asked me is it possible to open an EXE file from Siebel?

I thought it should be and started doing some work on it. Finally found the code which you can use to launch EXE files from Siebel. I tested this code to open notepad on click of a button.


 COMCreateObject cannot be used in Browser Script, so I wrote that code in Applet Server Script but I believe it should also work on BusComp Server Script.

Code:

if(MethodName == “YourMethodName”)
      {
          var oShell = COMCreateObject(“Shell.Application”);
          var commandtoRun = “C:\\Winnt\\Notepad.exe”;
          // Invoke the execute method. 
         oShell.ShellExecute(commandtoRun, “”,””, “open”, “1”);
         return(CancelOperation);
      }

Explanation:

I used Shell API provided by windows to interact with various applications. You can also provide parameters such as filepath of the file that you want to open in the notepad as 2nd argument. You can check the syntax of SHELL API if you are interested in exploring these commands further.

In this code though,

We are creating an instance of Shell API and then using ShellExecute Method to invoke Notepad without any arguments. Similarly you can open applications like Internet Explorer, Microsoft Word and Excel etc.

Hope this helps :)


13 Responses to COMCreateObject – Opening an EXE File.

  1. Hi Piyush,

    Is this is a question? If it is then the answer is yes we can open any website using this functionality.

    You will need to open internet explorer with argument as your website URL.

  2. Hi Piyush,

    Is this is a question? If it is then the answer is yes we can open any website using this functionality.

    You will need to open internet explorer with argument as your website URL.

  3. Hi,

    Could you please advise if there is somewhere in the .cfg file to enable/disable the COM object, from my understanding, it should be automatically registered to the dll when compiling the code.

  4. Hi,

    Could you please advise if there is somewhere in the .cfg file to enable/disable the COM object, from my understanding, it should be automatically registered to the dll when compiling the code.

  5. Just as a note, you should be able to use this in browser script using the following format:

    var oShell = new ActiveXObject(“Shell.Application”);

  6. Just as a note, you should be able to use this in browser script using the following format:

    var oShell = new ActiveXObject(“Shell.Application”);

  7. hi Neel, thanks for the above information, but can i invoke another application in mobile client (when i am not connected to server), where the server side scripts doesnot execute?, you understood what i am asking right?.. hope i am clear with the question.

  8. hi Neel, thanks for the above information, but can i invoke another application in mobile client (when i am not connected to server), where the server side scripts doesnot execute?, you understood what i am asking right?.. hope i am clear with the question.

Leave a Reply

Contribute