OK. Here is the code. On 150 PC's the path variable is dead. The Value that i want to change is right and programm runs but the commands net use,regedit,cmd... are dead. Please Help
Code:
$CValue = "\\rassmus\terawin\system"
$RValue = "\\geodaten\terawin\system\"
$RC1 = PathMod($CValue, $RValue)
$CValue = "\\rassmus\terawin\system\"
$RC2 = PathMod($CValue, $RValue)
; $CValue = "\\geodaten\terawin\system\"
; $RValue = "\\geodaten\terawin\system"
$RC3 = PathMod($CValue, $RValue)
; Rckgabewerte :
; 0 Eintrag wurde gefunden und Pfad wird gendert
; 1 Fehler : Eintrag konnte nicht geschrieben werden
; 2 $CValue wurde nicht gefunden oder ist leer
; 3 $RValue wurde nicht gefunden oder ist leer
;
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)
$RegType = READTYPE($KeyLoc,$KeyNam)
$Array = Split($KeyVal,";",-1)
For Each $Element In $Array
If $Element = $CValue
$Array[$acntr] = $RValue
$stat = "TRUE"
EndIf
$acntr = $acntr + 1
Next
If $Stat = "TRUE"
For Each $Element In $Array
If $fCntr = 0
$KeyVal2 = $element
$fcntr = 1
Else
$keyVal2 = $KeyVal2 +";"+ $Element
$fcntr = $fcntr + 1
EndIf
Next
$RC = WriteValue($Keyloc,$KeyNam,$KeyVal2,"REG_EXPAND_SZ")
; $RC = WriteValue($Keyloc,$KeyNam,$KeyVal2,$REGTYPE) // Wegen Problem ausnahmsweise auf REG_EXPAND_SZ .....
; SETM "Path=$KeyVal2"
If $RC = 0
$PathMod = 0
Return
Else
$Pathmod = 1
Return
EndIf
EndIf
EndFunction
added code tags - Bullock