How to turn "abc.exe" to abc in Command Line [duplicate] - command-line

This question already has answers here:
Adding a directory to the PATH environment variable in Windows
(21 answers)
Closed 6 months ago.
I want to run this command line: "C:\Program Files\LOVE\love.exe" "C:\games\mygame"
But it's too long, can i turn this into: love "C:\games\mygame"?

You have to add C:\Program Files\LOVE\ to the PATH environment variable. This way, the command can be found from the commandline without explicitly specifying the path.
See https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them on what environment variables are and how to set them in Windows.

Related

What's the equivalent of 'set -e' (exit on any errors) in Powershell? [duplicate]

This question already has answers here:
How to stop a PowerShell script on the first error?
(11 answers)
Closed 3 years ago.
I've been using Unix for about 20 years, but only started using Powershell recently. I have a ps1 script that does a number of tasks.
I know I could check each of them, and throw if they error, but it would be good for the entire script just to exit on any errors - like set -e does in bash.
How can I make a Powershell script exit immediately upon any error?
Using pwsh 6.2.1.
Having just found the answer to my own question:
ErrorActionPreference does this.
$ErrorActionPreference='Stop'
at the top of the ps1 file.

Use environment variable in path and argument in the same command [duplicate]

This question already has answers here:
Powershell chmod on /tmp/hive for winutils and hadoop/spark
(1 answer)
Safest way to run BAT file from Powershell script
(8 answers)
Closed 3 years ago.
I have created an environment variable IGNITE_HOME and then want to use this variable to execute a program in PowerShell as well as passing arguments
If I run the following two commands separately, it works fine:
cd $env:IGNITE_HOME/bin
./ignite.bat $env:IGNITE_HOME/examples/config/example-cache.xml
but If I try to run it in one line, it does not work:
$env:IGNITE_HOME/bin/ignite.bat $env:IGNITE_HOME/examples/config/example-cache.xml
I get an error message:
You must provide a value expression following the '/' operator.
At line:1 char:18
I tried to add double quotes on the arguments, but that did not help either

Set shell variable with help perl script [duplicate]

This question already has answers here:
How do I set an environment variable in Perl?
(5 answers)
Closed 6 years ago.
I was trying to set shell variable name with help of perl script.
But it was not running fine.
system("variable_name=\"variable_value\"");
`variable_name=\"variable_value\"`;
Any one tell me why it was not working.
Actually my question was little bit different.
I want to know how to set environment "setenv" with help of perl script.
I have tried
$ENV{"VARIABLE_NAME"} = "home\/path_1\/path_2\/path_3";
Then I fire command echo $VARIABLE_NAME then it is not giving me path that I set from perl script.
Thanks
You have no need to run a new shell to set an environment variable; indeed, doing so is counterproductive, since the value doesn't outlive the shell in which it's assigned (except through any surviving children of that shell which may have inherited the value).
You can simply set an environment variable directly in your perl:
$ENV{"variable_name"} = "variable_value"
Any subsequent shell you start from your perl script will see this.
It was working. The problem is that the next system command runs a new shell which doesn't know about variables set in the first shell.
system 'x=value; echo $x'; # Outputs "value".
system 'echo $x'; # Empty line - the shell with $x doesn't exist anymore.

Startup Parameters within the Script? [duplicate]

This question already has answers here:
Is there a way to programmatically set the ApartmentState to STA?
(2 answers)
Closed 7 years ago.
I have a script that needs to run in single-threaded mode, and I currently start it up with the -sta parameter with a batch. Is it possible to run the script in -sta mode only executing the Script? I thought about moving the whole script into one function and execute this function in single-threaded mode.
Is that possible? I don't want to give out a batch file and my ps1.
I think if you were to get PowerGUI and put the script into this, you would be able to package the PS1 file into an exe file which can just be executed like a normal program.
Once PowerGUI is installed you can do this from Tools, Complile Script.

how to run the perl script in the directory which i specify while running the script in the command line [duplicate]

This question already has answers here:
How do I cd into a directory using perl?
(3 answers)
Closed 9 years ago.
How to run the perl script in the directory which i specify while running the script in the command line
Example:
./scriptname -rd run
My script should go to directory name run and it should run there?
Do a chdir() in your Perl script.
cf http://perldoc.perl.org/functions/chdir.html
The obvious solution is to chdir to the directory before running the script:
dir=$(readlink -f .)
cd run
"$dir"/scriptname