aa2zz6 Posted November 19, 2016 Posted November 19, 2016 (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 November 19, 2016 by aa2zz6
Moderators JLogan3o13 Posted November 19, 2016 Moderators Posted November 19, 2016 (edited) Look at the macros in the help file: @ComputerName, @UserProfileDir, @DesktopDir, etc. Edited November 19, 2016 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!
aa2zz6 Posted November 19, 2016 Author Posted November 19, 2016 (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 November 19, 2016 by aa2zz6
dmob Posted November 19, 2016 Posted November 19, 2016 (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 November 19, 2016 by dmob
Bowmore Posted November 19, 2016 Posted November 19, 2016 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 aa2zz6 1 "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
aa2zz6 Posted November 19, 2016 Author Posted November 19, 2016 Thanks! I appreciate the help JLogan, dmob and Bowmore.
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