Add environment variable to install4j - install4j

Is it possible to add environment variable to install4j once, instead of add this variable under the "Specify environment variable" field?
for example i want to add JAVA_VENDOR=Sun once and each time i will use "Run executable or batch file" action this variable will be recognized by the running process.
Thanks in Advance,
Maxim

Yes you can do it with setx command.
See setx /? for more info.
Setx "JAVA_VENDOR" "Sun once"
PD: Remember the CMD uses the set profile at this moment, I mean if you try to ser a voiremental variable directly in a CMD instance you'll need to close and re-open cmd to see the changes.
Bye.

Related

add new environment variable [system] using power shell

I am trying to add new Environment variable in my windows 10 system , i am using below powershell command to add System variable
$env:ITH_PYTHON_PATH = 'C:\Python27\Python.exe'
i can see command is successful in adding the new values, and i can get back value when i use command $env:ITH_PYTHON_PATH.
I cannot see updated path when i manually go to the system property Environment variable
After reboot $env:ITH_PYTHON_PATH is also not seen.
Is there any better way to add environment variable permanently?
Would something like this work?
[Environment]::SetEnvironmentVariable("ITH_PYTHON_PATH", "C:\Python27\Python.exe", "Machine")

Can't remove %PATH% variable?

I'm using Windows 10.
I somehow added a variable to %PATH% in the command line (I don't remember how), and it now shows up when I type echo %PATH%. However, when I go to the GUI Environment Variables, that certain variable appears neither in the Path of "User variables for [my_username]" nor the Path of "System variables".
How do I find where I can edit %PATH% and remove the variables I need to remove?
You most certainly used "set" to change a environment variable for the current cmd.exe. The change does only affect the currently running cmd.exe process.
see also: https://ss64.com/nt/set.html

$env:PSModulePath versus %PSModulePath%

How comes cmd.exe shows different values for PSModulePath than PowerShell does?
PowerShell:
\\share\user\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
CMD:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
The environment variables seems to be modified 'localy' at execution ( changes are not saved to the system ).
Running cmd from within the powershell console should work as you expect :
PS>cmd /c echo %psmodulepath%
Anytime you start up PowerShell it will create a set of environment variables for that session. These can all be found under the $env (ex. $env:PSModulePath). There is a set of default values that go here. These default values are hard corded but you can of course modify those default values by changing it in one of the profile script locations.
As for CMD.exe, whenever it starts up it too will create environment variables, however it's environment variables are pulled from the OS environment.
Go to Control Panel -> System -> Advanced Settings -> Advanced Tab -> Environment Variables

Can a Batch script know if it's called from PowerShell?

Is there any way a batch script can know if it's called from PowerShell (without extra parameters feeded)?
Need something like..
if (%THIS_BATCH_CALLED_FROM_POWERSHELL%)
... warn the user or drop back to powershell to execute the proper instructions...
Question related with this question - virtualenv-in-powershell.
You could use a tool like "tlist.exe /t" or this one to display the PIDs of the current process and all parent processes. You could check each one of those PIDs to see if any correspond to PowerShell.exe.
You could add a default warning in the script and pass it a flag that tells it not to show the warning. When you call it from power shell pass it that flag.
In my Powershell environment (a PS 2.0 CTP), I seem to have an environment variable PSMODULEPATH which is not set by the normal command line environment, but still exists when Powershell has a child CMD.exe shell.
I think you might be able to "reliably enough" check for the existence of PSMODULEPATH in your batch script.

Why is the Powershell Environment PATH different to the System Environment PATH?

I'm having this weird situation :
My user's and system's PATH variable is different than the PATH in powershell.
When I do :
PS C:\$env:path
C:\Windows\System32\WindowsPowerShell\v1.0\;c:\oldpath
However this is not correct, it looks like it stuck on some old PATH variable of my system, so none of the udpates I've done on it didn't change this variable (I do restart after every change to test).
Why is this happening? Do I have to set a PATH variable just for powershell?
The change might be "delayed", so try one or more of these solutions:
Log off and on again;
Task Manager > Restart "Windows Explorer" (explorer.exe)
Restart your launcher app (launchy, SlickRun, etc)
Reboot
Explanation:
Powershell will inherit the environment of the process that launched it (which depends on how you launch it). This is usually the interactive shell (explorer.exe). When you modify the environment from computer properties, you modify the environment of explorer.exe, so if you launch powershell from explorer.exe, (for example from the start menu) you should see the new environment.
However, if you launch it from something else (say a cmd.exe shell that you already had opened), then you won't since that process was launched under the old environment.
In other words: be careful how you are launching things.
In my case, I installed an app that incorrectly added itself to the PATH by creating a powershell profile that would override $env:PATH and blow out the existing configuration every time I started powershell.
Check if you have profile at USER\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 and if it's doing anything fishy like setting $env:PATH.