Jump to content

Recommended Posts

Posted (edited)

How would I replace or bypass PC name aa2zz6 with something that can be universal for any computer.

So if I had ArcGIS Desktop on my home computer verses my work computer the PC names would be different.

C:\Users\aa2zz6\Desktop\ArcGIS Desktop

 

Edited by aa2zz6
Posted (edited)

I wasn't able to get it to work with this. 

@ComputerName & "/desktop"

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()

    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = @UserProfileDir & "/desktop"

    ; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
    IniWrite($sFilePath, "General", "Title", "AutoIt")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the key labelled 'Title'.
    IniDelete($sFilePath, "General", "Title")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the INI file.
    ;FileDelete($sFilePath)
EndFunc   ;==>Example

 

Edited by aa2zz6
Posted (edited)
6 hours ago, aa2zz6 said:

I wasn't able to get it to work with this. 

@ComputerName & "/desktop"

 

Maybe: @UserProfileDir & "\Desktop" ?

or just:

@DesktopDir ?

Edited by dmob
Posted

This work for me. You must supply a file name to read and write to not just a directory

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()

    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = @DesktopDir & "\MyInifile.ini" ;<== You must supply a file name for iniwrite() and iniread() to use

    ; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
    IniWrite($sFilePath, "General", "Title", "AutoIt")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the key labelled 'Title'.
    IniDelete($sFilePath, "General", "Title")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the INI file.
    ;FileDelete($sFilePath)
EndFunc   ;==>Example

 

 

 

"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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...