But if I open a new cmd window by right-clicking a folder and selecting
"command prompt", the window does not inherit system variables set earlier
in the same session.
My "command prompt" folder option is set up with this reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\OpenCMDWindow]
@="Command Prompt"
[HKEY_CLASSES_ROOT\Directory\shell\OpenCMDWindow\Command]
@="C:\WINDOWS\system32\cmd.exe"
[HKEY_CLASSES_ROOT\Drive\shell\OpenCMDWindow]
@="Command Prompt"
[HKEY_CLASSES_ROOT\Drive\shell\OpenCMDWindow\Command]
@="C:\WINDOWS\system32\cmd.exe"
--
BTW, those lines do have double \\ in the actual reg file. An editing error
got into the post.
REGEDIT4
[HKEY_CLASSES_ROOT\Directory\shell\OpCmdWin]
@=" ======== Command Prompt ========"
[HKEY_CLASSES_ROOT\Directory\shell\OpCmdWin\command]
@="D:\\windows\\SYSTEM32\\cmd.exe /T:17 /k \"Mode Con: Cols=100
Lines=40&cd \"%1\"\""
[HKEY_CLASSES_ROOT\Drive\shell\OpCmdWin]
@=" ======== Command Prompt ========"
[HKEY_CLASSES_ROOT\Drive\shell\OpCmdWin\command]
@="D:\\windows\\SYSTEM32\\cmd.exe /T:17 /k \"Mode Con: Cols=100
Lines=40&cd \"%1\"\""
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
Yes, setx worked normally and changed the registry values.
Also, editing the system environment in system properties behaves the same
as setx. After doing that I get the same results from new command windows
as with setx. The normal command window inherits the changes but windows
opened with "command window here" have the environment the system booted
with.
So the issue is that cmd windows are different when opened that way.
My best guess is that cmd windows opened that way inherit their environment
from the explorer window where I right-clicked the folder. On a hunch I
just confirmed this by turning off "launch folder windows in a separate
process". Now they inherit the latest environment. But that doesn't really
explain it. I would think that if each one is a new process then it should
inherit the latest changes.
I want folder windows in a new process for stability and for the ability to
open folders as a different user, but I expect there's no way around this.
--
set var1>c:\temp\restore.bat
set var2>>c:\temp\restore.bat
..
..
..
..
..
set varn>>c:\temp\restore.bat
and maybe a line with
path>>c:\temp\restore.bat
Then when you want to get the right env vars,
execute c:\temp\restore.bat
all that assumes the presence of directory c:\temp of course .
Some variables have to be in the non-volatile system environment.
--
x-posted to: microsoft.public.win2000.cmdprompt.admin
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
"Tom Del Rosso" wrote:
> Yes, setx worked normally and changed the registry values.
>
> Also, editing the system environment in system properties behaves the same
> as setx. After doing that I get the same results from new command windows
> as with setx. The normal command window inherits the changes but windows
> opened with "command window here" have the environment the system booted
> with.
>
> So the issue is that cmd windows are different when opened that way.
>
> My best guess is that cmd windows opened that way inherit their
> environment from the explorer window where I right-clicked the folder. On
> a hunch I just confirmed this by turning off "launch folder windows in a
> separate process". Now they inherit the latest environment. But that
> doesn't really explain it. I would think that if each one is a new
> process then it should inherit the latest changes.
>
> I want folder windows in a new process for stability and for the ability
> to open folders as a different user, but I expect there's no way around
> this.
>
> --
>
>
> Dave Patrick wrote:
>> Do you find them here?
>>
>> HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
>
>>>"Tom Del Rosso" wrote:
>>>Using XP Pro SP3, if I set a variable with setx, then open a new cmd
>>>window and type set, the variable is shown.
>>>But if I open a new cmd window by right-clicking a folder and selecting
>>>"command prompt", the window does not inherit system variables set
>>>earlier in the same session.
>>>My "command prompt" folder option is set up with this reg file:
>>>Windows Registry Editor Version 5.00
>>>[HKEY_CLASSES_ROOT\Directory\shell\OpenCMDWindow]
>>>@="Command Prompt"
>>>[HKEY_CLASSES_ROOT\Directory\shell\OpenCMDWindow\Command]
>>>@="C:\WINDOWS\system32\cmd.exe"
>>>[HKEY_CLASSES_ROOT\Drive\shell\OpenCMDWindow]
>>>@="Command Prompt"
>>>[HKEY_CLASSES_ROOT\Drive\shell\OpenCMDWindow\Command]
==
Cheers, Tim Meddick, Peckham, London.
"Dave Patrick" <DSPa...@nospam.gmail.com> wrote in message
news:On2Xp%230yJH...@TK2MSFTNGP06.phx.gbl...
--
Regards,
Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
==
Cheers, Tim Meddick, Peckham, London.
"Dave Patrick" <DSPa...@nospam.gmail.com> wrote in message
news:O6M9vk2y...@TK2MSFTNGP02.phx.gbl...
Thanks.
Hi Tim,
| I can confirm that it happens because of Explorer being set to launch
| "as a separate process". In this case, it does not "inherit" env
| vars because explorer only updates it's environment with every new
| instance of explorer. i.e. set an environment variable in a command
| window using setx and if you IMMEADIATLY open a NEW explorer window
| and right-click on a folder and select 'Command Prompt' it WILL
| display the new variable. However, if the instance of explorer was
| ALREADY OPEN at the same time as the command windows set the new
| variable, then it WILL NOT show the new variable because that
| Explorer was isolated by being an 'instance' separate and it's
| environment is also separate. A new instance of explorer carries the
| updated Window's environment. However, ALL OPEN EXPLORER INSTACES
| HAVE TO CLOSE before a 'new' instance will uptake the new set of
| variables.
You're right and it's exactly to avoid this issue that I wrote the tool
DynSetEnv :
http://glsft.free.fr/index.php?option=com_content&task=view&id=67&Itemid=28
To make a variable available in current and new instances of explorer :
\> DynSetEnv -name testvar -value test -recurse
Hope this helps.
--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr
Regards
Are there any reviews in English or German?
Regards
Hi Matthias,
| just discovered your console WSH Shell - looks very interesting,
| mais je ne pas parlez Francais, seule un petit peux ;-)
| Are there any reviews in English or German?
No translation of the tutorials is available for the moment but I think
the commands can help. However the integrated help system is available
in english. To discover builtin commands, functions, subs and
properties, just type _gethelp at the command prompt. To run a
script-block interactively, you have to use a backtick at the first line
and use an empty line to close the script block. For example :
WSH D:\Test> For i=0 To 10 `
>> WScript.StdOut.Write i+1 & " "
>> Next
>>
1 2 3 4 5 6 7 8 9 10 11
WSH D:\Test>
WSH Shell Console :
http://glsft.free.fr/index.php?option=com_content&task=category§ionid=4&id=19&Itemid=28
Note: The tutorials are available at the end of the page. You have to
begin to read the last one.
Best regards.
==
Cheers, Tim Meddick, Peckham, London.
"Gilles LAURENT [MVP]" <gl...@free.fr> wrote in message
news:utKYcOWz...@TK2MSFTNGP03.phx.gbl...
Thanks for your feedback ;-)