Forum Discussion
6 Replies
Sort By
Hi Christophe,
I suspect that you get this message as the path to your executable file is specified incorrectly. Please pay attention to that all of the files specified to be opened in the command line must be referenced using the full path to the file. If the file path contains spaces, it should be enclosed in quotes (""). Also please note that you can use the GetEnvironmentVariable method to get the ProgramFiles environment variable.
Look at the example:
Sub OpenTestApplication
Dim WshShell
Set WshShell = Sys.OleObject("WScript.Shell")
command = """" & aqEnvironment.GetEnvironmentVariable("ProgramFiles") & "\MyApp\app.exe"""
Log.Message command
Call WshShell.Run(command)
End Sub
If this does not help, please post here the problematic code.- Hi Saurabh,
You can use the Run and Exec methods of the WScript.Shell object.
The following code demonstrates how to launch Notepad using the Run method:function RunNotepad()
{
var path;
path = '"C:\\Windows\\Notepad.exe"';
WS = new ActiveXObject("WScript.shell");
WS.Run(path);
Log.Message("Notepad is running");}
I hope this helps. - DevChamindaOccasional ContributorHi Lexi,
Can I have the VB scripts of this please, I tried but no luck so far. - DevChamindaOccasional ContributorI slove the issue following is the VB scripts sample , this open the test application which on given file location.
Sub OpenTestApplication
Dim WshShell, WshShellExec
' Open test application
Set WshShell = Sys.OleObject("WScript.Shell")
Set WshShellExec = WshShell.Exec("C:\MyApp\bin\TestApp.exe")
End Sub - CBleunvenContributorHi to all,
I try to apply the proposed solution to my tests but I have a problem working with the "Program Files" directory.
When I try with C:\\Windows\\Notepad.exe, it works, but when I try with C:\\Program Files\\MyApp\\app.exe it fails with the following JScript runtime error message : "The system cannot find the file specified".
If I previously test the path with aqFileSystem.Exists(path), the result is True.
I guess the issue is the space in the folder name, how may I solve this ?
Thank you for help,
Best,
Christophe - CBleunvenContributorHi David,
It works now with " surrounding.
Thanks for your help.
Christophe
Related Content
- 2 years agosanket2799
- 3 years agoMichal_Ignaczak
Recent Discussions
- 2 days agoMW_Didata