SubList in Switch

Antworten
NIck
Beiträge: 4
Registriert: 04 Mai 2022, 09:49

SubList in Switch

Beitrag 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
Benutzeravatar
SisterOfMercy
Beiträge: 1522
Registriert: 22 Jun 2012, 19:18

Re: SubList in Switch

Beitrag 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.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
NIck
Beiträge: 4
Registriert: 04 Mai 2022, 09:49

Re: SubList in Switch

Beitrag 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
Benutzeravatar
SisterOfMercy
Beiträge: 1522
Registriert: 22 Jun 2012, 19:18

Re: SubList in Switch

Beitrag von SisterOfMercy »

And if you have multiple video cards installed, will it always be the fourth entry in $Grafikkarte$?
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
NIck
Beiträge: 4
Registriert: 04 Mai 2022, 09:49

Re: SubList in Switch

Beitrag 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.
Benutzeravatar
SisterOfMercy
Beiträge: 1522
Registriert: 22 Jun 2012, 19:18

Re: SubList in Switch

Beitrag 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.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
NIck
Beiträge: 4
Registriert: 04 Mai 2022, 09:49

Re: SubList in Switch

Beitrag 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?
Benutzeravatar
SisterOfMercy
Beiträge: 1522
Registriert: 22 Jun 2012, 19:18

Re: SubList in Switch

Beitrag von SisterOfMercy »

Code: Alles auswählen

DefStringList $result$
DefVar $RegistryKey$
DefVar $testName$
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
Antworten