sg_winforum Posted April 18, 2009 Report Share Posted April 18, 2009 Hello, I would like to use relative links for Windowsexplorer. The only way I found was to set and environment variable and then use this variable for the link. I tried to set the environment variable with the batch command "reg add". This creates/changes the registry entry. But the variable is not yet active. With the script below the following happens: Step 1:"c" will create the variable _test. This can be checked by pressing "r". If I open a new cmd and enter "set _test", the variable "_test" results as not defined. Step 2:If I open start - settings - control panel - system - advanced - Environment Variables, _test is defined. If I click "Ok" (or "Edit" - "Ok" - "Ok") and then open a new cmd and enter "set _test", the variable "_test" is correctly defined. Now my question: Does anyone know, how to perform Step 2 automatically without a new login? BRgregHere is the test script: @ECHO OFFecho:echo:ECHO This will set an environment variable "_test" :BEGINNecho:Echo use current drive path © use Server path (s) Echo open regedit and show variable ®Echo Abort (a)set /P eingabe=if %eingabe% == c goto currentif %eingabe% == s goto serverif %eingabe% == r goto open_regeditif %eingabe% == a goto ENDEgoto BEGINN:currentset temp_current_folder=%CD%reg add HKEY_CURRENT_USER\Environment /v _test /d "%temp_current_folder%" /frem is there a difference? reg add HKCU\Environment /v _test /d "%temp_current_folder%" /fECHO:ECHO _test has been set to ECHO:reg query HKEY_CURRENT_USER\Environment /v _testGOTO BEGINN:serverreg add HKEY_CURRENT_USER\Environment /v _test /d "\\test_server\test_path" /fECHO:ECHO _test has been set to ECHO:reg query HKEY_CURRENT_USER\Environment /v _testGOTO BEGINN:open_regeditset LastKey="HKEY_CURRENT_USER\Environment"set Key=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regeditreg add %Key% /f /v "LastKey" /d %LastKey%start regedit.exeGOTO BEGINN:ENDE Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted April 20, 2009 Report Share Posted April 20, 2009 "set _test", the variable "_test" results as not defined.How do you determine that the variable is not defined?P.S. to show code in forum posts, it is best done within tags (or [html] tags in case of HTML code). I have modified your post accordingly. Quote Link to comment Share on other sites More sharing options...
sg_winforum Posted April 20, 2009 Author Report Share Posted April 20, 2009 Hi, to see, if the variable is defined: start - run - cmdtype "set _test" Then I read the answer: "Environment variable _test not defined"or in case it was set to "old_value" (before login) and afterwards to "new_value": type "set _test"Then I read the answer: "_test=old_value"BR Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted April 21, 2009 Report Share Posted April 21, 2009 Maybe reading the Help file for the set command will give you some ideas (see attachment).set.txt Quote Link to comment Share on other sites More sharing options...
sg_winforum Posted April 21, 2009 Author Report Share Posted April 21, 2009 Maybe reading the Help file for the set command will give you some ideas (see attachment).set.txtThanksI had a look on this but I didn't find anything. The set command is always temporary. Then I decided to try out the Windows XP SP2 Support Tools. (It's not the best solution, because an aditional program is required...) The solution is: Use the setx.exe from http://www.microsoft.com/downloads/details...;displaylang=enI tried this on WinXPx32 and WinXPx64 just by using the setx.exe without installing the support tools. This works fine: Setting variable _test = "test1"\\server_with_setx\path_to_setx\setx.ex _test "test1"or, if setx.exe has been copied to C:\WINNT (on a x32 machine):setx _test "test1"Deleting _test:\\server_with_setx\path_to_setx\setx.exe _test ""or setx _test ""(It's quite interesting: reg add HKEY_CURRENT_USER\Environment /v _test /d "test1" /fsetx _test2 "test2"results in both variable beeing available to a new cmd)So farGreg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.