Page 1 of 1 1
Topic Options
#124046 - 2004-07-28 01:00 PM environment path edit
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
hello,
i need to check HKLU environment path for reference to a UNC path. If the path exists, remove it. I've tried searching various topics but can't tailor anything for my needs. here is what i have so far (very poor i know but i'm trying).

$reg=ReadValue('HKEY_CURRENT_USER\Environment','Path')
if 'path' = "\\server\netlogon"
"yes"
else
"no"
endif

now, i know this is incorrect, it always returns no because there are other entries in the path. any help would be appreciated.

Top
#124047 - 2004-07-28 01:03 PM Re: environment path edit
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Should it be

Code:
  
$reg=ReadValue('HKEY_CURRENT_USER\Environment','Path')
if $reg = "\\server\netlogon"
"yes"
else
"no"
endif


_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#124048 - 2004-07-28 01:07 PM Re: environment path edit
otf Offline
Getting the hang of it

Registered: 2003-11-21
Posts: 53
Loc: Scotland
but it will still return 'no' as the path will resemble something like
C:\winnt;c:\program files;\\server\netlogon;c:\winnt\system32

so as that does not = \\server\netlogon then it will return 'no'

all i need to do if search specifically for the UNC reference and delete it


Edited by otf (2004-07-28 01:09 PM)

Top
#124049 - 2004-07-28 01:12 PM Re: environment path edit
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
maybe use

if INSTR($reg ,"\\server\netlogon")
"Its been found"
endif
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#124050 - 2004-07-28 01:14 PM Re: environment path edit
Anonymous
Unregistered


yeah, that does some good
i'll work on that, thanks friend

Top
#124051 - 2004-07-28 02:50 PM Re: environment path edit
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Since you want to remove it, that is not the best way to go. Use Split() to break the path into array elements and then AScan() to search for the element. Then reassemble the elements, leaving out the one you don't want and write it back.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124052 - 2004-07-28 02:54 PM Re: environment path edit
Anonymous
Unregistered


yeah, i have been searching for a method of 'deleting' the referenced UNC but without luck. I'll look into your suggestion, thanks
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.064 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org