Page 1 of 1 1
Topic Options
#121603 - 2004-06-21 10:09 PM Using kixtart to modify path statement?
skelm Offline
Lurker

Registered: 2004-06-21
Posts: 2
I need to modify the path statement for 400 users on login. The change only needs to occur once. Is there a way I could use kixtart to do this?

I need to remove something in the path and replace with something else. Any help would be appreciated.

Top
#121604 - 2004-06-21 10:14 PM Re: Using kixtart to modify path statement?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
What do you wanna change? Be more specific

Btw. Welcome to KORG.


Edited by Co (2004-06-21 10:15 PM)
_________________________
Co


Top
#121605 - 2004-06-21 10:51 PM Re: Using kixtart to modify path statement?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First, load the %PATH% elements into an array like this:
Code:
$Path = Split(ExpandEnvironmentVars('%PATH%'),';')


Then use ASCan() to see if what you want is in the path or not. If it is, move on else add it with whichever SET, SETL, or SETM suits you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#121606 - 2004-06-21 11:00 PM Re: Using kixtart to modify path statement?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Make sure you rebuild the array into a new string that includes the new value you want Before using one of the Set's to set it. Dont want to set %PATH% to just your new value...that wouldnt be good.
Top
#121607 - 2004-06-21 11:40 PM Re: Using kixtart to modify path statement?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Of course... my post was just a starter waiting for clarification to CO's question.

One of the path elements need to be replaced, according to skelm.
Quote:

I need to remove something in the path and replace with something else



Not having all the details, have not provided code on a silver platter but basically it is just a matter of using AScan() to find the old element number and replacing the element and then Join()ing the array back together and writing it out to the appropriate environment.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#121608 - 2004-06-22 12:54 AM Re: Using kixtart to modify path statement?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I know you're new to the board in posting but not sure if you're new to KiXtart or not.

If you know how to use UDFs then you might be able to use this UDF.

PathMod() Modify System Variable
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=107085

I think there is another one as well to do this.

Top
#121609 - 2004-06-22 03:00 PM Re: Using kixtart to modify path statement?
skelm Offline
Lurker

Registered: 2004-06-21
Posts: 2
I guess I should have been a little more specific.

What I need to do is modify the path statement like this.

I am starting with c:\blah;c:\somethingelse;c:\changeme2;c:\yetsomethingelse and I need to change it do something like c:\blah;c:\somethingelse;c:\changeme3;c:\yetsomethingelse.. It's a very small change.

I have been using kixtart for a while, but never for anythign complex.

Top
#121610 - 2004-06-22 05:11 PM Re: Using kixtart to modify path statement?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I think you were specific enough...every suggestion so far should do exactly what youre wanting to do. Did you look at the UDF that Doc posted? In your case...you could use the UDF and do something like this...

Code:
$null = PathMod("c:\changeme2","c:\changeme3")

Function PathMod($CValue, $RValue)
Dim $Array, $aCntr, $KeyVal2, $fCntr, $stat, $KeyLoc, $Keynam
$aCntr = 0
$fCntr = 0
$stat = "FALSE"
$KeyLoc = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$keyNam = "Path"

If $CValue = "" OR $RValue = ""
Select
Case $CValue = ""
$Pathmod = 2
Case $RValue = ""
$Pathmod = 3
EndSelect
Return
EndIf

$KeyVal = ReadValue ($KeyLoc, $KeyNam)
$Array = Split($KeyVal,";",-1)
For Each $Element In $Array
If $Element = $CValue
$Array[$acntr] = $RValue
$stat = "TRUE"
EndIf
$acntr = $acntr + 1
Next
For Each $Element In $Array
If $fCntr = 0
$KeyVal2 = $element
$fcntr = 1
Else
$keyVal2 = $KeyVal2 +";"+ $Element
$fcntr = $fcntr + 1
EndIf
Next
If $Stat = "TRUE"
$RC = WriteValue($Keyloc,$KeyNam,$KeyVal2,"REG_SZ")
If $RC = 0
$PathMod = 0
Return
Else
$Pathmod = 1
Return
EndIf
EndIf
EndFunction


Top
#121611 - 2004-06-22 06:57 PM Re: Using kixtart to modify path statement?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I think you were specific enough...




Not quite. Depends on what environment needs to be updated, local or machine. I think admin rights would be needed for machine.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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.037 seconds in which 0.021 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