Jump to content

Standardize PC name for any file directory


aa2zz6
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

Look at the macros in the help file: @ComputerName, @UserProfileDir, @DesktopDir, etc.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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