Archive: Search path functions


Search path functions
  Hi!

I have written some functions for adding/removing directories from the search path of Windows. They work for NT (without restart) and 9x.

I will be happy to see them in the functions.html file or contrib folder so they can help others but me :D

KiCHiK


Hi,

Some (possibly only older editors) can put EOF characters into the file, in which case the approach you use will fail (as your "SET" would never get executed).

Just a warning,
Dennis


Thanks Dennis!

After looking in the code again, I have found out that somehow some old code got into it. I have now attached the newest code from my installer script with (I hope) all of the corrections needed.

Please download this version instead of the earlier one.

About your comment, I don't really understand what you mean. Do these editors put EOF in the middle of the file? If so, how else can I seek for the EOF?


Originally posted by kichik


About your comment, I don't really understand what you mean. Do these editors put EOF in the middle of the file? If so, how else can I seek for the EOF?
In the good old days editors added a special EOF character (stupid but true) to files (the reason for the /A /B switches on a copy command), most (all?) programs (including Windows reading autoexec.bat etc) still stop reading at the EOF character.

From memory the EOF character was decimal 26, if I'm wrong then it was 27.

I don'y know how common this would be but I have seen this myself so I know it does happen (I tried to do exactly what your code does).

Bye,
Dennis

RefreshEnv
  Hi,

Thanks for posting the path script. It would be helpful for me to get also the source for RefreshEnv or if you could explain what exactly it contains (Api call)

Greetings,
Andreas
:)


Here is the API function called:

DWORD dwReturnValue;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);

KiCHiK


RefreshEnv Api function
  Thanks kichik,

Will implement the function in an exe.

Greetings,
Andreas


Kichik,

I have looked at your zip file and the archive example on sourgefourge. It is almost exactly what I am looking for. In both cases you change HKLU\Enviorment Path Key (which is for the logedon user). But in my case I want to append the path for all the users, HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\ Path key (As far as I know this is the right key). I have modified your code to change this key instead. It does append the path, but it seems to fix the %SystemRoot% to a string instead of a variable, eg (in dos)

Before addation:

path=c:\winnt\system\;c:\winnt\

After addition of c:\foo
path=%SystemRoot%;%SystemRoot%\system;c:\foo

Do you have any suggestions?

Thanks,

Ross


Use WriteRegExpandStr instead of WriteRegStr and it should keep the variables.


Thanks, works a treat!

Ross


I am using Windows XP and when I uninstall everthing seems to work fine. When I check the path it looks ok, but when I try to type in commands that were accessible in my path I can't. Has anybody had this problem yet?


Lately i used this function:
http://nsis.sourceforge.net/Path_Manipulation

But i had to set timeout=1000 otherwise my explorer will crash badly
(tried several installations/deinstallations with it)


SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 

>
HTH

If Explorer itself crashes, you probably have some rouge shell extension.


no - my system works fine. and the crash happend when opening START - Programs - <subfolder>, not anywhere else.
It exactly happend when i set timout=5000 and right after the (de-)installation (both concerned).
i can do vice versa many times without reboot...
BTW the system timeout here is set to 5000 instead windows default 20000 (all values in milli seconds).

it was this line which crashes my explorer (explorer + task bar/desktop).
It was added to the script which works well.


Fine, then it's not a rouge shell extension.


finally i will see when user is using the installer - but till
now no negative feedback (ok i build it in as an option). thx


trojan >> RefreshEnv.exe


False positive. Anyway, the SendMessage solution is simpler.