aa2zz6

Standardize PC name for any file directory

7 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Edited by JLogan3o13

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

I tried those and it doesn't work. 

Share this post


Link to post
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

 

 

 

1 person likes this

"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

Thanks! I appreciate the help JLogan, dmob and Bowmore.

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