Forum Discussion
I'm making an assumption here that the path you are describing is to the executable for the desktop application you wish to test. We needed the same capability to launch the app regardless of where it was installed. We accomplished it by getting the application path from the registry. This method works for us regardless of where the application is installed.
The registry key we use is written automatically at install time. This is typical for Windows applications because it's the path Windows uses to find the application when you double-click on an associated file. Below is sample code (VBScript) showing how you could launch Adobe Acrobat 2020 with his method.
Here is the registry key we reference to find the EXE location (In this example Acrobat):
Our function returns "True" if it was successful launching the app.
Function b_LaunchInstalledApp
b_LaunchInstalledApp = False
Dim s_AppExeLocation
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
'Get the application path and assign it to the variable s_AppExeLocation
objRegistry.GetStringValue HKEY_CLASSES_ROOT, "acrobat2020\shell\Open\command", "", s_AppExeLocation
Set objRegistry = Nothing
'If the path is not empty launch the application and set the function to return True. If empty the function will return False.
If (s_AppExeLocation <> Empty) Then
s_AppExeLocation = aqString.Replace(s_AppExeLocation, " " + aqString.Quote("%1"), "")
If aqFileSystem.Exists(s_AppExeLocation) Then
'Launch the app
Call WshShell.Run(aqString.Quote(s_AppExeLocation))
b_LaunchInstalledApp = True
End If
End If
End Function
I hope that helps.
Related Content
- 6 years ago
- 4 years ago
- 6 years ago
Recent Discussions
- 2 days ago