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 :)


Contribute