Jump to content

iniread seems to fail in loop matching scenario for processlist()


Recommended Posts

#NoTrayIcon

$list = ProcessList()

for $i = 1 to $list[0][0]

Global $n = IniRead("av.ini", "av", $list[$i][0], "1")

If $n = 1 Then

IniWrite("nagger.ini", "nag", "nag", $list[$i][0])

Run("nagger.exe")

EndIf

next

the ini file is as follows:

[av]

AvastUI.exe=1

and it just goes on like that in this manner

Link to comment
Share on other sites

  • Moderators

Topic moved from Example Scripts forum to General Help.

Please be more aware where you are posting in the future.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I've no idea what you're specific issue is, but this example will show it works.

Global $s_ini_file = "Testingini.ini"
; Setup ini file to test
IniWrite($s_ini_file, "Exes", '"SVCHost.exe"', "0")

Global $s_ini_read = ""
Global $s_err_ret = "**Does Not Exist**"
Global $a_processlist = ProcessList()

For $i = 1 To $a_processlist[0][0]
    $s_ini_read = IniRead($s_ini_file, "Exes", '"' & $a_processlist[$i][0] & '"', $s_err_ret)

    If $s_ini_read = $s_err_ret Then
        ConsoleWrite("Error:   " & $a_processlist[$i][0] & " does not exist in the ini file" & @CRLF)
    Else
        ConsoleWrite("Success: " & $a_processlist[$i][0] & " does exist and its value is: " & $s_ini_read & @CRLF)
    EndIf
Next

If you have a svchost.exe running, you'll see a success, all others will be an error.

Edit:

Also remember, that IniRead returns a "String" not an Integer ( as you're using it ), if you need to use it as an Integer, then you need to do something like: Int(IniRead(etc, etc, etc, etc))

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...