Jump to content
Sign in to follow this  
StickyChopstix

Iniwrite saves in a different directory

Recommended Posts

StickyChopstix

#include <String.au3>

If FileExists("settings.ini") Then
    Call("wmccheck")
Else
    $user = InputBox("Security Check", "Enter your username.", "")
    $user2 = _StringEncrypt(1, $user, "123", 1)
    ;IniWrite("settings.ini", "login", "Username", $user2)
    $pass = InputBox("Security Check", "Enter your password.", "", "*")
    $pass2 = _StringEncrypt(1, $pass, "456", 1)
    ;IniWrite("settings.ini", "login", "Password", $pass2)
    $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;   IniWrite("settings.ini", "files", "WMC", $wmc)
    EndIf
    $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;   IniWrite("settings.ini", "files", "ACE", $ace)
    EndIf
    Call("writeini")
    Call("wmccheck")
EndIf

Func writeini()
IniWrite("settings.ini", "login", "Username", $user2)
IniWrite("settings.ini", "login", "Password", $pass2)
IniWrite("settings.ini", "files", "WMC", $wmc)
IniWrite("settings.ini", "files", "ACE", $ace)
EndFunc

The only thing I want it to do here is write the settings.ini files into the same directory as the exe. But it always write into the $ace directory. Why does this happen?

Share this post


Link to post
Share on other sites
enaiman

It looks like you haven't specified a location for your ini file.

However your post is not clear enough to help me understand what you want.

This script works:

#include <String.au3>

If FileExists(@ScriptDir&"\settings.ini") Then
    Call("wmccheck")
Else
    $user = InputBox("Security Check", "Enter your username.", "")
    $user2 = _StringEncrypt(1, $user, "123", 1)
    ;IniWrite("settings.ini", "login", "Username", $user2)
    $pass = InputBox("Security Check", "Enter your password.", "", "*")
    $pass2 = _StringEncrypt(1, $pass, "456", 1)
    ;IniWrite("settings.ini", "login", "Password", $pass2)
    $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;   IniWrite("settings.ini", "files", "WMC", $wmc)
    EndIf
    $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;   IniWrite("settings.ini", "files", "ACE", $ace)
    EndIf
    Call("writeini")
    Call("wmccheck")
EndIf

Func writeini()
    IniWrite(@ScriptDir&"\settings.ini", "login", "Username", $user2)
    IniWrite(@ScriptDir&"\settings.ini", "login", "Password", $pass2)
    IniWrite(@ScriptDir&"\settings.ini", "files", "WMC", $wmc)
    IniWrite(@ScriptDir&"\settings.ini", "files", "ACE", $ace)
EndFunc

Take note how the ini file's location needs to be specified (@ScriptDir&"\settings.ini").

Also - if the ini file does not exist yet - you need to create it bofore any reading/writing.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Bowmore

#include <String.au3>

If FileExists("settings.ini") Then
    Call("wmccheck")
Else
    $user = InputBox("Security Check", "Enter your username.", "")
    $user2 = _StringEncrypt(1, $user, "123", 1)
    ;IniWrite("settings.ini", "login", "Username", $user2)
    $pass = InputBox("Security Check", "Enter your password.", "", "*")
    $pass2 = _StringEncrypt(1, $pass, "456", 1)
    ;IniWrite("settings.ini", "login", "Password", $pass2)
    $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;    IniWrite("settings.ini", "files", "WMC", $wmc)
    EndIf
    $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;    IniWrite("settings.ini", "files", "ACE", $ace)
    EndIf
    Call("writeini")
    Call("wmccheck")
EndIf

Func writeini()
IniWrite("settings.ini", "login", "Username", $user2)
IniWrite("settings.ini", "login", "Password", $pass2)
IniWrite("settings.ini", "files", "WMC", $wmc)
IniWrite("settings.ini", "files", "ACE", $ace)
EndFunc

The only thing I want it to do here is write the settings.ini files into the same directory as the exe. But it always write into the $ace directory. Why does this happen?

FileOpenDialog changes the current directory 

You need to specify the directory of the ini file.

Try this.

#include <String.au3>

 If FileExists(@scriptdir & "\settings.ini") Then
    Call("wmccheck")
Else
    $user = InputBox("Security Check", "Enter your username.", "")
    $user2 = _StringEncrypt(1, $user, "123", 1)
    ;IniWrite(@scriptdir & "\settings.ini", "login", "Username", $user2)
    $pass = InputBox("Security Check", "Enter your password.", "", "*")
    $pass2 = _StringEncrypt(1, $pass, "456", 1)
    ;IniWrite(@scriptdir & "\settings.ini", "login", "Password", $pass2)
    $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;    IniWrite(@scriptdir & "\settings.ini", "files", "WMC", $wmc)
    EndIf
    $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1)
    If @error Then
        Exit
    ;Else
    ;    IniWrite(@scriptdir & "\settings.ini", "files", "ACE", $ace)
    EndIf
    Call("writeini")
    Call("wmccheck")
EndIf

Func writeini()
IniWrite(@scriptdir & "\settings.ini", "login", "Username", $user2)
IniWrite(@scriptdir & "\settings.ini", "login", "Password", $pass2)
IniWrite(@scriptdir & "\settings.ini", "files", "WMC", $wmc)
IniWrite(@scriptdir & "\settings.ini", "files", "ACE", $ace)
 EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
StickyChopstix

Ah thanks a lot. @scriptdir was EXACTLY what I was looking for. It couldn't find it in the directory macros so I gave up looking for those.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.