Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arguments to pass while using Extern.ShellExecute command in QTP
#1
Solved: 11 Years, 4 Months ago MyBB 
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
Reply
#2
Solved: 11 Years, 4 Months ago
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"

Reply
#3
Solved: 11 Years, 4 Months ago
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Telnet command not recognized Sanjana1987 1 2,060 09-20-2017, 03:16 PM
Last Post: Ankur
  WinListView set item command Shahino007 0 2,652 10-06-2015, 03:57 PM
Last Post: Shahino007
  PASS/FAIL in QTP badri 3 6,218 12-05-2014, 03:26 AM
Last Post: kiranpol
  Same command needs to be performed twice to actually perform it pistaa 2 2,924 04-25-2014, 01:26 PM
Last Post: pistaa
Exclamation Getting run time error while executing the QTP script in command prompt. vishruth143 1 5,659 07-15-2013, 05:41 PM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 1 Guest(s)