Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.

How do I launch an application without using the Default BaseState or Application States?

How do I launch an application without using the Default BaseState or Application States?

SilkTest Classic uses the Default BaseState and Application States to start your application for testing. There may be a scenario in which you do not want this powerful behaviour to execute.

Using a DLL call to the Shell32.dll, you can use the built in function ShellExecuteA to launch your application(s).
NB make sure your appstate is set to none.

The 4Test script below uses ShellExecuteA to:

  1. Launch IE 6 browser
  2. SilkTest then closes IE 6 browser
  3. Launch NotePad

Sample Code launchie6_Then_app().t (attached):

[-] dll "shell32"
[ ]
[ ] int ShellExecuteA (int hwnd, String lpOperation, String lpFile, string lpParameters,String lpDirectory, int nShowCmd)
[ ]
[-] testcase launchie6_Then_app() appstate none

[ ]
[ ] int iHandle = Desktop.GetHandle()
[ ] //The path to the executable
[ ] string lpFile = "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
[ ]
[ ] // The operation that is to be carried out
[ ] string lpOperation = "open"
[ ]
[ ] // Any additional parameters to the commandline
[ ] string lpParameters = " "
[ ]
[ ] // The working directory in which this will be run
[ ] string lpDirectory = "C:\Temp"
[ ]
[ ] // a flag that determines how the command will be shown
[ ] int iShowCmd = 5
[ ]
[ ] //Launch IE6
[ ] ShellExecuteA(iHandle,lpOperation,lpFile,lpParameters,lpDirectory,iShowCmd)
[ ] Sleep(10) //insert script
[ ] Browser.Close() //Close IE6
[ ]
[ ] //launch notepad
[ ] lpFile = "C:\WINDOWS\system32\notepad.exe"
[ ] ShellExecuteA(iHandle,lpOperation,lpFile,lpParameters,lpDirectory,iShowCmd)
[ ] Sleep(5) //insert script
[ ]
[ ]

Sample script:  Launch2apps.t

Related documents:

Old KB# 21106

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:16
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.