Seite 1 von 1

Registry-Kommande "supp" und Variable

Verfasst: 09 Feb 2011, 10:57
von bernhardus
Hallo,

wenn ich in einer Registry-Sektion das Kommando "set" benutze, kann ich auf vorher definierte Variablen zurückgreifen.
Geht das auch mit dem Kommando "supp"? Daran bin ich nämlich bislang gescheitert...

Beispiel (s. Winst-Handbuch S. 109):

Code: Alles auswählen

DefVar $Path$
DefVar $AddToPath$
set $Path$ = EnvVar ("Path")
set $AddToPath$="c:\orawin\bin"
Registry_PathPatch

[Registry_PathPatch]
openkey [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\control\SessionManager\Environment]
set "Path"="$Path$"
supp "Path"; "$AddToPath$"
Als Ergebnis steht bei mir im Pfad dann
...;$AddToPath$
, d. h. die Variable wurde nicht durch ihren Wert ersetzt. Ich habe auch nocht keinen Weg gefunden, wie ich das bewerkstelligen könnte.

Hintergrund der Aktion ist, daß die Windows-Umgebungsvariable %ProgramFiles% im Pfad nicht expandiert wird (im Gegensatz bspw. zu %SystemRoot%). Da wir mit 32bit und 64bit sowie mit deutschen und englischen Windows-Versionen arbeiten, ist eine Angabe des Programmverzeichnisses als Variable mehr als wünschenswert.

Re: Registry-Kommande "supp" und Variable

Verfasst: 09 Feb 2011, 18:47
von d.oertel
Hi,

kann das Problem nicht nachvollziehen.
Vielleicht hilft das Beispiel (leich modifiziert aus dem Produkt opsi-winst-test)
Bei mir gibt der Code:

Code: Alles auswählen

	comment ""
	comment "-------------------------------------"
	comment "Testing: "
	message "Supp"
	set $tmp$="value1;value2;value3"
	Registry_Supp
	set $ConstTest$ = "value;"+$tmp$
	set $CompValue$ = GetRegistryStringValue ("[HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test] test")
	if ($ConstTest$ = $CompValue$)
		comment "passed"
	else
		set $TestResult$ = "not o.k."
		LogWarning "failed"
	endif

[Registry_Supp]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test]
supp "test" ; "$tmp$"
den log:

Code: Alles auswählen

[5] [09.02.2011 18:41:22]   comment: 
[5] [09.02.2011 18:41:22]   comment: -------------------------------------
[5] [09.02.2011 18:41:22]   comment: Testing: 
[5] [09.02.2011 18:41:22]   message Supp
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   Set  $tmp$="value1;value2;value3"
[6] [09.02.2011 18:41:23]     The value of the variable "$tmp$" is now: "value1;value2;value3"
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   Execution of Registry_Supp
[7] [09.02.2011 18:41:23]     Registry started with redirection (32 Bit)
[7] [09.02.2011 18:41:23]     Key is: HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test
[7] [09.02.2011 18:41:23]     Key0 is: HKEY_LOCAL_MACHINE
[6] [09.02.2011 18:41:23]     Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test]  opened
[6] [09.02.2011 18:41:23]         Variable "test"   supplemented with "value1;value2;value3"
[6] [09.02.2011 18:41:23]         Key closed
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   Set  $ConstTest$ = "value;"+$tmp$
[6] [09.02.2011 18:41:23]     The value of the variable "$ConstTest$" is now: "value;value1;value2;value3"
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   Set  $CompValue$ = GetRegistryStringValue ("[HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test] test")
[7] [09.02.2011 18:41:23]   Registry started with redirection (32 Bit)
[6] [09.02.2011 18:41:23]     Registry key [HKEY_LOCAL_MACHINE\SOFTWARE\opsi.org\opsi-winst-test]  opened
[6] [09.02.2011 18:41:23]     Key closed
[6] [09.02.2011 18:41:23]     The value of the variable "$CompValue$" is now: "value;value1;value2;value3"
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   If
[5] [09.02.2011 18:41:23]     $ConstTest$ = $CompValue$   <<< result true
[5] [09.02.2011 18:41:23]     ($ConstTest$ = $CompValue$)   <<< result true
[5] [09.02.2011 18:41:23]   Then
[5] [09.02.2011 18:41:23]     comment: passed
[5] [09.02.2011 18:41:23]   
[5] [09.02.2011 18:41:23]   Else
[5] [09.02.2011 18:41:23]   EndIf
gruss
d.oertel

Re: Registry-Kommande "supp" und Variable

Verfasst: 11 Feb 2011, 09:02
von bernhardus
Hallo,

danke für die schnelle Antwort. Ich werde im Laufe der nächsten Woche das Ganze noch einmal prüfen und melde mich dann wieder.

Re: Registry-Kommande "supp" und Variable

Verfasst: 15 Feb 2011, 13:10
von bernhardus
Ja, es funktiniert. Warum dsa beim ersten Mal nicht ging kann ich leider nicht mehr nachvollziehen.

Danke nochmals.