WhaleJesus Posted August 25, 2021 Share Posted August 25, 2021 (edited) 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. expandcollapse popup#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 August 25, 2021 by WhaleJesus "and i have full admin rights Link to comment Share on other sites More sharing options...
Solution spudw2k Posted August 25, 2021 Solution Share Posted August 25, 2021 (edited) I think your Local $DataFile inside your Create function is overruling your Global. Edited August 25, 2021 by spudw2k WhaleJesus and Danp2 2 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
WhaleJesus Posted August 25, 2021 Author Share Posted August 25, 2021 11 minutes ago, spudw2k said: I think your Local $DataFile inside your Create function is overruling your Global. Somehow coding makes me feel more stupid every day 😂, thanks a lot!! Link to comment Share on other sites More sharing options...
Danp2 Posted August 25, 2021 Share Posted August 25, 2021 A strategically placed ConsoleWrite would have identified the issue right away. You might want to give that a shot next time. WhaleJesus 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
WhaleJesus Posted August 26, 2021 Author Share Posted August 26, 2021 Thanks, i just tried it out and it doesn't seem nearly as complicated as i thought it would be 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