Seite 1 von 1

SubList in Switch

Verfasst: 04 Mai 2022, 10:43
von NIck
Guten Tag,

Ich möchte ein String aus einem powershellCall mit einigen anderen Strings vergleichen und eine Ausgabe herausgeben.
Ich habe versucht StringList in meinem Switch zu verwenden das funktioniert aber leider nicht.

Code: Alles auswählen


[Actions]

DefStringList $Grafikkarte$
DefStringList $Test$

set $Grafikkarte$ = powershellCall('wmic path win32_VideoController get name')
set $Test$ = getSubList(4 : 4, $Grafikkarte$)

Switch $Test$
	Case "*NVIDIA Geforce GTX 1060*"
		Message "1060"
	EndCase
	Case "*NVIDIA Geforce*"
		Message "NVIDIA"
	EndCase
	DefaultCase
	Message "Grafikkarte unbekannt"
	EndCase
EndSwitch

Im Voraus vielen Dank

Re: SubList in Switch

Verfasst: 04 Mai 2022, 14:07
von SisterOfMercy
Comparing a stringlist to a string probably doesn't work. You will need to compare each entry in the stringlist to the string. What are the contents of $Grafikkarte$ and $Test$?


Workaround:

Code: Alles auswählen

Set $result$ = getRegistryKeyListSysnative("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}")
for $value$ in $result$ do Sub_network_wake_on_lan	

[Sub_network_wake_on_lan]
set $RegistryKey$ = "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" + "$value$" + "]"
Set $testName$ = GetRegistryStringValueSysNative($RegistryKey$ + "DriverDesc")
if contains($testName$,"82579")
	Registry_install_Intel_82579
endif
if contains($testName$,"82574")
	Registry_install_Intel_82574
endif
if (contains($testName$,"I217") or contains($testName$,"I210"))
	Registry_install_Intel_217
endif
if contains($testName$,"I354")
	Registry_install_Intel_354
endif
if contains($testName$,"82566")
	Registry_install_Intel_82566
endif
if contains($testName$,"nForce")
	Registry_install_Nvidia_nForce
endif
if (contains($testName$,"AR8121") or contains($testName$,"AR8113") or contains($testName$,"AR8114"))
	Registry_install_Atheros_AR8121
endif
if contains($testName$,"Realtek PCIe")
	Registry_install_Realtek_PCIe
endif

[Registry_install_Intel_354]
openkey $RegistryKey$
set "EnablePME" = "1"
set "*WakeOnMagicPacket"="1"
set "*WakeOnPattern"="1"

[Registry_install_Intel_217]
openkey $RegistryKey$
set "EnablePME" = "1"
set "*WakeOnMagicPacket"="1"
set "*WakeOnPattern"="1"

[Registry_install_Intel_82579]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Intel_82574]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Intel_82566]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Nvidia_nForce]
openkey $RegistryKey$
set "EthWOLFromPowerOff" = "1"
set "WakeUpMagic" = "1"
set "WakeUpPattern" = "1"

[Registry_install_Atheros_AR8121]
openkey $RegistryKey$
set "ShutdownWake" = "1"
set "WakeUpCapabilities" = "3"

[Registry_install_Realtek_PCIe]
openkey $RegistryKey$
set "S5WakeOnLan" = "1"
set "WolCap" = "3"
In your case, the key for display adapters is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}
The same DriverDesc can be used.

Re: SubList in Switch

Verfasst: 04 Mai 2022, 15:35
von NIck
das sind die Werte der Variablen:

$Grafikkarte$ =
(string 0)Name
(string 1)
(string 2)Microsoft Remote Display Adapter
(string 3)
(string 4)NVIDIA GeForce GTX 960
(string 5)
(string 6)
(string 7)

$Test$ =
(string 0)NVIDIA GeForce GTX 960

Re: SubList in Switch

Verfasst: 04 Mai 2022, 16:16
von SisterOfMercy
And if you have multiple video cards installed, will it always be the fourth entry in $Grafikkarte$?

Re: SubList in Switch

Verfasst: 04 Mai 2022, 16:31
von NIck
Wir haben keine Rechner mit mehreren Grafikkarten. Aber ein guter Einwand, ich weiß nicht welchen Output andere Grafikkarten haben.
Das hätte ich noch Getestet.

Also gibt es keine Möglichkeit ein Stringlist mit einem String zu vergleichen?

Ich werde dein Workaround mal versuchen.

Vielen dank für den Einwand.

Re: SubList in Switch

Verfasst: 04 Mai 2022, 16:36
von SisterOfMercy
NIck hat geschrieben: 04 Mai 2022, 16:31 Also gibt es keine Möglichkeit ein Stringlist mit einem String zu vergleichen?
You will have to use a for schleife.
In the workaround, $result$ is a stringlist.
so that kinda works the same. either use a sub or do a direct comparison.

Re: SubList in Switch

Verfasst: 05 Mai 2022, 13:29
von NIck
SisterOfMercy hat geschrieben: 04 Mai 2022, 14:07 Comparing a stringlist to a string probably doesn't work. You will need to compare each entry in the stringlist to the string. What are the contents of $Grafikkarte$ and $Test$?


Workaround:

Code: Alles auswählen

Set $result$ = getRegistryKeyListSysnative("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}")
for $value$ in $result$ do Sub_network_wake_on_lan	

[Sub_network_wake_on_lan]
set $RegistryKey$ = "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" + "$value$" + "]"
Set $testName$ = GetRegistryStringValueSysNative($RegistryKey$ + "DriverDesc")
if contains($testName$,"82579")
	Registry_install_Intel_82579
endif
if contains($testName$,"82574")
	Registry_install_Intel_82574
endif
if (contains($testName$,"I217") or contains($testName$,"I210"))
	Registry_install_Intel_217
endif
if contains($testName$,"I354")
	Registry_install_Intel_354
endif
if contains($testName$,"82566")
	Registry_install_Intel_82566
endif
if contains($testName$,"nForce")
	Registry_install_Nvidia_nForce
endif
if (contains($testName$,"AR8121") or contains($testName$,"AR8113") or contains($testName$,"AR8114"))
	Registry_install_Atheros_AR8121
endif
if contains($testName$,"Realtek PCIe")
	Registry_install_Realtek_PCIe
endif

[Registry_install_Intel_354]
openkey $RegistryKey$
set "EnablePME" = "1"
set "*WakeOnMagicPacket"="1"
set "*WakeOnPattern"="1"

[Registry_install_Intel_217]
openkey $RegistryKey$
set "EnablePME" = "1"
set "*WakeOnMagicPacket"="1"
set "*WakeOnPattern"="1"

[Registry_install_Intel_82579]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Intel_82574]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Intel_82566]
openkey $RegistryKey$
set "EnablePME" = "1"
set "WakeOn"="118"

[Registry_install_Nvidia_nForce]
openkey $RegistryKey$
set "EthWOLFromPowerOff" = "1"
set "WakeUpMagic" = "1"
set "WakeUpPattern" = "1"

[Registry_install_Atheros_AR8121]
openkey $RegistryKey$
set "ShutdownWake" = "1"
set "WakeUpCapabilities" = "3"

[Registry_install_Realtek_PCIe]
openkey $RegistryKey$
set "S5WakeOnLan" = "1"
set "WolCap" = "3"
In your case, the key for display adapters is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}
The same DriverDesc can be used.


Dürfte ich fragen als was du deine Variablen Initialisiert hast?

Re: SubList in Switch

Verfasst: 05 Mai 2022, 14:10
von SisterOfMercy

Code: Alles auswählen

DefStringList $result$
DefVar $RegistryKey$
DefVar $testName$