COMCreateObject – Opening an EXE File.
By neel | January 21, 2008
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
Subscribe by Email
January 22nd, 2008 at 1:14 am
Nice Blog ….. we can also open the any website using this funcation also…..
January 22nd, 2008 at 1:20 am
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.
May 19th, 2008 at 8:57 pm
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.