Hi,
Could you please help me with the below query.
I have started a command prompt and the PATH (global path) set in it is as below:
Path=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;;C:\ACTIVE~1\BIN;C:\Program Files\TortoiseSVN\bin
In this command prompt I reset the PATH to
Path=C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;
Then If I start a new command prompt using "cmd.exe /c start" then in the new command prompt it shows the PATH which I re-setted above. Where as I am interested in seeing the global path(which is available before starting the new cmd prompt)
in the new spawned cmd prompt.
Could you please let me know what is the proper way to start a new command prompt to achieve this.
Thanks
Siva
How to inherit the global path in a new command prompt
Moderator: DosItHelp
Re: How to inherit the global path in a new command prompt
Code: Select all
start /i cmd.exe
Where the /i switch instructs start command to use the original environment of the current cmd instance.
Re: How to inherit the global path in a new command prompt
Thanks for your reply.
I have a question further.
Is there a way to start a new cmd window to use the environment from the global environment variables (the ones we see from the mycomputer--->properties).
Thanks
Siva
I have a question further.
Is there a way to start a new cmd window to use the environment from the global environment variables (the ones we see from the mycomputer--->properties).
Thanks
Siva
Re: How to inherit the global path in a new command prompt
Thanks all for your replies.
1) I have a cmd prompt where the below path is set.
Path=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;
2) In this command prompt I invoke an ant script which installs some new products and set some extra path and perl path
Path=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;%some_extra_path%;%perl_path%;
3) Later in the same ant program I run a java program which invokes a perl command internally.
Now the issue is, when the java program invokes perl command it says the perl is not found in the path.
But the perl path is set by the ant program which is not visible/inherited to the java program.
I tried to execute the perl using "cmd.exe /c start perl" in the java program, thinking that spawning a new cmd prompt will get the latest path being set (i.e. perl path) but no luck. The path is still showing the old path and I get the perl not found error.
Any pointers to get the perl command executed from the java code properly using the path already set.
1) I have a cmd prompt where the below path is set.
Path=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;
2) In this command prompt I invoke an ant script which installs some new products and set some extra path and perl path
Path=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;%some_extra_path%;%perl_path%;
3) Later in the same ant program I run a java program which invokes a perl command internally.
Now the issue is, when the java program invokes perl command it says the perl is not found in the path.
But the perl path is set by the ant program which is not visible/inherited to the java program.
I tried to execute the perl using "cmd.exe /c start perl" in the java program, thinking that spawning a new cmd prompt will get the latest path being set (i.e. perl path) but no luck. The path is still showing the old path and I get the perl not found error.
Any pointers to get the perl command executed from the java code properly using the path already set.
Re: How to inherit the global path in a new command prompt
This is a little bit beyond batch file programming, but what you are going to have to do is set the path spec for every cmd session. I know there's a place to do that in xp under control panel-->system. Good luck.