WhaleJesus Posted August 25, 2021 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
Solution spudw2k Posted August 25, 2021 Solution Posted August 25, 2021 (edited) I think your Local $DataFile inside your Create functionΒ is overruling your Global. Edited August 25, 2021 by spudw2k Danp2 and WhaleJesus 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 Β
WhaleJesus Posted August 25, 2021 Author 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!! Β
Danp2 Posted August 25, 2021 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
WhaleJesus Posted August 26, 2021 Author Posted August 26, 2021 Thanks, i just tried it out and it doesn't seem nearly as complicated as i thought it would be
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