Micro Focus QTP (UFT) Forums
Arguments to pass while using Extern.ShellExecute command in QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Arguments to pass while using Extern.ShellExecute command in QTP (/Thread-Arguments-to-pass-while-using-Extern-ShellExecute-command-in-QTP)



Arguments to pass while using Extern.ShellExecute command in QTP - ShrikantBiradar3449 - 11-11-2010

Hi guys,

I am using an existing code given below but not clear with the sequence of arguments passed in "Extern.ShellExecute " statement.
This code is to run a .bat file stored at location "C:\Share\Shri\shridos.bat" using Extern object of QTP

I am expecting more about the mandatory arguments and their sequence while using "ShellExecute" method in QTP. i.e line2

line1:
Code:
Extern.Declare micInteger , "ShellExecute", "shell32.dll", "ShellExecuteA" , micLong, micString, micString,  micString, micString, micLong

line2:
Code:
Extern.ShellExecute 0, "open", "C:\Share\Shri\shridos.bat","C:\Share\Shri" ,"", 1



RE: Arguments to pass while using Extern.ShellExecute command in QTP - Saket - 11-11-2010

Parameters for Shellexecute function are (in sequence)
hwnd - Long, Optional : handle to the owner window used
lpOperation - String,Optional : a verb, that specifies the action to be performed. could be like edit, explore, open etc
lpFile - String,Required : specifies the file or object on which to execute the specified operation
lpParameters - String,Optional: specifies an executable file
lpDirectory -String,Optional : default (working) directory for the action
nShowCmd - Long, Required (Not 100% sure about required/optional) : flag that specify how an application is to be displayed when it is opened

hope this will help you.
by the way why dont you use a bit easier way to run a batch file using Wscript.shell
e.g.
Code:
Dim oShell
Set oShell = CreateObject ("Wscript.shell")'
oShell.run "C:\Share\Shri\shridos.bat"



RE: Arguments to pass while using Extern.ShellExecute command in QTP - ShrikantBiradar3449 - 11-12-2010

Thanks Saket Its pretty useful for me.

There are few more .exe files that I want to run by passing some arguments.So I don't think with "Wscript.shell"
we can do that.