To run programs from JScript, you can use XSIUtils.LaunchProcess.
Here’s a simple example that does a dir on C:\Program Files, redirects the output to a text file, and then uses Notepad to open the text file:
var sPath = XSIUtils.Environment("TEMP"); XSIUtils.LaunchProcess( 'cmd /C "dir > ' + sPath + '\\dir222.txt"', false, "C:\\Program Files" ); XSIUtils.LaunchProcess( 'notepad ' + sPath + '\\dir222.txt', false, "C:\\" );
The third argument to LaunchProcess will be the current working directory of the launched process. So in the above example, I’m doing a dir of C:\Program Files (because cmd opens with C:\Program Files as its current directory).
If the exe is not in the system PATH, then you need to specify the full location:
var sCommandLine = "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe"; var sStartupDirectory = Application.InstallationPath( siWorkgroupPath ); XSIUtils.LaunchProcess( sCommandLine, false, sStartupDirectory );
In the above example, I’m using my workgroup location as the current directory, so when I do File > Open in Visual Studio, by default I will be looking in my workgroup location.