In File Explorer (or Windows Explorer), right-click the script file name and then select "Run with PowerShell". The "Run with PowerShell" feature starts a PowerShell session that has an execution policy of Bypass, runs the script, and closes the session.
You can start any application by specifying the full path to its executable: C:\Program Files\FileZilla FTP Client\filezilla.exe . You can optionally use Start-Process with the EXE if you want to capture a reference to the executable to gain more control over it from Powershell.
Running EXE Files (Windows) Double-click an EXE file to run it. EXE files are Windows executable files, and are designed to be run as programs. Double-clicking any EXE file will start it.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
& "C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe" C:\temp\TestProject1\TestProject1.pjs /run /exit /SilentMode
or
[System.Diagnostics.Process]::Start("C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe", "C:\temp\TestProject1\TestProject1.pjs /run /exit /SilentMode")
UPDATE: sorry I missed "(I invoked the command using the "&" operator)" sentence. I had this problem when I was evaluating the path dynamically. Try Invoke-Expression construction:
Invoke-Expression "& `"C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe`" C:\temp\TestProject1\TestProject1.pjs /run /exit /SilentMode"
It looks like you're specifying both the EXE and its first argument in a single string e.g; '"C:\Program Files\Automated QA\TestExecute 8\Bin\TestExecute.exe" C:\temp\TestProject1\TestProject1.pjs /run /exit /SilentMode'
. This won't work. In general you invoke a native command that has a space in its path like so:
& "c:\some path with spaces\foo.exe" <arguments go here>
That is &
expects to be followed by a string that identifies a command: cmdlet, function, native exe relative or absolute path.
Once you get just this working:
& "c:\some path with spaces\foo.exe"
Start working on quoting of the arguments as necessary. Although it looks like your arguments should be just fine (no spaces, no other special characters interpreted by PowerShell).
In the Powershell, cd to the .exe file location. For example:
cd C:\Users\Administrators\Downloads
PS C:\Users\Administrators\Downloads> & '.\aaa.exe'
The installer pops up and follow the instruction on the screen.
Demo:
$exePath = $env:NGINX_HOME + '/nginx.exe'
$myArgs = $args.Clone()
$myArgs += '-p'
$myArgs += $env:NGINX_HOME
& $exepath $myArgs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With