gcue Posted April 21, 2008 Share Posted April 21, 2008 how can i handle multiple conditions that are met within a function.. for instance.. if the PING fails, i dont want it to try the other REG READS that follow. i tried ELSEIF, but i think u can only use that once. any ideas? expandcollapse popupFor $x = 1 to $assets[0] $status="1" $dacs="1" $usercode="1" Ping($assets[$x]) If @error Then $status="OFFLINE" $user="" $version="" $serial="" EndIf RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" ) If @error Then $status="NO_ADMIN_RIGHTS" $user="" $version="" $serial="" EndIf RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version") If @error Then $status="BLOOMBGER_NOT_INSTALLED" $user="" $version="" $serial="" EndIf Dim $status, $user, $version, $serial If $status = "1" Then $status = "" $user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser") $version = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version") $serial = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\User Info", "Serial Number") EndIf Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Share Posted April 21, 2008 for instance.. if the PING fails, i dont want it to try the other REG READS that follow.i tried ELSEIF, but i think u can only use that once.You can use elseif as many times as you like Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 when i did.. it breaks the FOR / NEXT loopYou can use elseif as many times as you like Link to comment Share on other sites More sharing options...
James Posted April 21, 2008 Share Posted April 21, 2008 $1 = 1 $2 = 2 $State = True If $1 + $2 = 3 And $State = True Then MsgBox(0, "", "Yup I win!") Else MsgBox(0, "", "Nope I lose!") EndIf Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Share Posted April 21, 2008 when i did.. it breaks the FOR / NEXT loopWhere's the next keyword? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Monamo Posted April 21, 2008 Share Posted April 21, 2008 (edited) how can i handle multiple conditions that are met within a function.. for instance.. if the PING fails, i dont want it to try the other REG READS that follow. i tried ELSEIF, but i think u can only use that once. any ideas? expandcollapse popupFor $x = 1 to $assets[0] $status="1" $dacs="1" $usercode="1" Ping($assets[$x]) If @error Then $status="OFFLINE" $user="" $version="" $serial="" EndIf RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" ) If @error Then $status="NO_ADMIN_RIGHTS" $user="" $version="" $serial="" EndIf RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version") If @error Then $status="BLOOMBGER_NOT_INSTALLED" $user="" $version="" $serial="" EndIf Dim $status, $user, $version, $serial If $status = "1" Then $status = "" $user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser") $version = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version") $serial = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\User Info", "Serial Number") EndIfDepending on how you structure it, you can use multiple ElseIf entries. But for the sake of readability, you could add a basic error counter to wrap each task section, wherein if an error is detected (per entry in $assets), the following tasks would be skipped for that particular asset entry: CODE For $x = 1 to $assets[0] $iErrorCount = 0 $status="1" $dacs="1" $usercode="1" Ping($assets[$x]) If @error Then $status="OFFLINE" $user="" $version="" $serial="" $iErrorCount =+1 EndIf If $iErrorCount = 0 Then RegRead... ... EndIf If $iErrorCount = 0 Then RegRead... ... EndIf If $iErrorCount = 0 Then RegRead... ... EndIf Next Edited April 21, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 smaaaaaaaaart! Depending on how you structure it, you can use multiple ElseIf entries. But for the sake of readability, you could add a basic error counter to wrap each task section, wherein if an error is detected (per entry in $assets), the following tasks would be skipped for that particular asset entry: CODE For $x = 1 to $assets[0] $iErrorCount = 0 $status="1" $dacs="1" $usercode="1" Ping($assets[$x]) If @error Then $status="OFFLINE" $user="" $version="" $serial="" $iErrorCount =+1 EndIf If $iErrorCount = 0 Then RegRead... ... EndIf If $iErrorCount = 0 Then RegRead... ... EndIf If $iErrorCount = 0 Then RegRead... ... EndIf Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now