Jump to content

IniWrite returning zero on a file that is not read only


Go to solution Solved by spudw2k,

Recommended Posts

Hey all, i am once again having trouble with IniWrite, the file is stored in C:\Documents\AutoItScripts\GameHub and i have full admin rights (I'm trying to make a program to track how much time i spend playing non-steam games, which turned into an idea for a game library of sorts, nothing to do with game automation besides launching them with shellexecute wait or however i decide to do this).

The problem is IniWrite is returning 0 on a file that is not marked as read-only, and i have no idea why.

 

#include <FileConstants.au3>
;#RequireAdmin

; Choose game and multiple files to run when Game is launched

Global $DataFile, $ListN


$DataFile = @ScriptDir & "\DataFile.ini"
$ListN = IniRead($DataFile, "List", "Total", "Error")
;MsgBox(0, "", $DataFile)

If $ListN = "Error" Then
    MsgBox(0, "Error", 'Variable "Total" in Data.ini does not exist')
    Exit
EndIf


Create()

Func Create()

    Local $DataFile, $Name, $SpecifyAmount, $MainFile, $MainFileStringSplit, $NextFile, $AmountConfirm



    While 1

        $Name = InputBox("Enter Name", "What is the game called?")
        $AmountConfirm = MsgBox(4, "", "Should multiple programs be run?")

        If $AmountConfirm = 7 Then
            $SpecifyAmount = 1
            ExitLoop
        Else
            $SpecifyAmount = InputBox("Specify amount", "How many files?")

            #cs
            If IS($SpecifyAmount) = True Then
                ExitLoop
            Else
                MsgBox(0, "Bruh", "Please enter a number")
            EndIf
            #ce

        EndIf



    WEnd

    While 1

        $MainFile = FileOpenDialog("Choose Main game file or shortcut", "", "All (*.*)", $FD_FILEMUSTEXIST)
        $MainFileStringSplit = StringSplit($MainFile, ".")
        ;MsgBox(0, "", $MainFileStringSplit[$MainFileStringSplit[UBound]])

        If $MainFileStringSplit[$MainFileStringSplit[UBound]] = "exe" Or $MainFileStringSplit[$MainFileStringSplit[UBound]] = "lnk" Then
            ExitLoop
        Else
            MsgBox(0, "Bruh", "Please select .exe or .lnk file")
        EndIf

    WEnd

    $ListN = Number($ListN) + 1
    ;MsgBox(0, "", $ListN)

    IniWrite($DataFile, "List", "Total", $ListN)
    IniWrite($DataFile, "List", $ListN, $Name)
    IniWriteSection($DataFile, $Name, "Total=" & $SpecifyAmount & @LF & "File1=" & $MainFile)


    If Number($SpecifyAmount) > 1 Then

        For $i = 2 To $SpecifyAmount

            $NextFile = FileOpenDialog("Choose next file or shortcut", "", "All (*.*)", $FD_FILEMUSTEXIST)
            IniWrite($DataFile, $Name, "File" & $i, $NextFile)

        Next

    EndIf

EndFunc   ;==>Create

 

Edited by WhaleJesus
"and i have full admin rights
Link to comment
Share on other sites

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