Jump to content

Matching Computer Name


 Share

Recommended Posts

Can i have a bump on this thread. So i got the codes working but im having trouble implementing.

So the computer list on the text file if the program finds a match, the codes work i can get them to do certain thing, however if they are not in the list i want them to do another thing different from those on the list.

The problem is that it runs both the tasks for the computers in the list and the tasks assigned to the computers not on the list for the program scans the file each line.

Is there a way to find first the matching computer name on the list to the actual computer running the script so if it's a match, it executes the task intended for that computer and ends the script, but if there is no match, it redirects to another task rather than the code executing 1 by 1?

 

From post: 

 

 

1.txt

Edited by JLogan3o13
Link to comment
Share on other sites

  • Moderators

@brio2025 I have split your thread out and referenced the old one. In the future please do not resurrect old threads; the language has changed much in the last 6 years. What may have worked then may work differently today

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Easiest method would be to use an Ini for example:

[Computers]
ComputerName1 = Update
ComputerName2 = Leave

You could then use

Local $sComputerAction = IniRead("filename.ini", "Computers", @ComputerName, "")
Switch $sComputerAction
    Case "Update"
        ;~ Do an update
    Case "Leave"
        ;~ Do nothing
    Case ""
        ;~ Computer name wasn't in Ini so do something else.
EndSwitch

Alternatively you could use FileReadToArray and then _ArraySearch function to see if it can find a match or you could use FileRead and the use "If StringInStr($sFileRead, @ComputerName) Then ...."

Link to comment
Share on other sites

11 hours ago, Subz said:

Easiest method would be to use an Ini for example:

[Computers]
ComputerName1 = Update
ComputerName2 = Leave

You could then use

Local $sComputerAction = IniRead("filename.ini", "Computers", @ComputerName, "")
Switch $sComputerAction
    Case "Update"
        ;~ Do an update
    Case "Leave"
        ;~ Do nothing
    Case ""
        ;~ Computer name wasn't in Ini so do something else.
EndSwitch

Alternatively you could use FileReadToArray and then _ArraySearch function to see if it can find a match or you could use FileRead and the use "If StringInStr($sFileRead, @ComputerName) Then ...."

Thank you so much. This exactly what i needed

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...