Suppose I have a Windows commandline application (abc.exe
) in: C:\test
folder.
I've put my powershell script file in the same location too.
by using this command I set the current location to the location where my script is launched from:
Set-Location $PSScriptRoot
I need to run abc.exe
from within my script so that by pressing Control+C in the execution window of my script, it terminates abc.exe
too.
If I use this syntax: C:\test\abc.exe
in my script, everything is as what I want. but the problem is that I don't want to hard code the location of abc.exe
in my script since user may change it.(note: abc.exe
will always be in the same location as my script)
If I just use: abc.exe
I will get:
& : The term 'abc.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
What should I do?
Update: In windows Batch scripting, pressing Control+C in such situation will easily terminates both the execution of script and commandline application