aa2zz6 Posted November 23, 2016 Posted November 23, 2016 (edited) I have a .ini file that holds my path for our mapping software. I can't seem to get the CMD function to read the file path. I removed everything but the file path but it doesn't work. [ArcGIS Desktop] Path=C:\Users\<user name>\AppData\Local\ESRI\Desktop10.1\Launcher.exe Local Const $sFilePath = @ScriptDir & "\Mapping\Path\ " & "Path" & ".ini" Local $sFilewrite = IniWrite($sFilePath, "ArcGIS Desktop", "Path=", "C:\Users\aa2zz6\AppData\Local\ESRI\Desktop10.1\Launcher.exe") Start() Func Start() $MyCommand = $sFilewrite Run(@ComSpec & " /c " & $MyCommand, @SystemDir, @SW_HIDE) EndFunc ;==>Start Edited November 23, 2016 by aa2zz6
spudw2k Posted November 23, 2016 Posted November 23, 2016 how? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
aa2zz6 Posted November 24, 2016 Author Posted November 24, 2016 (edited) Credit to MHz for creating the CMD part. Creating the .ini file ;Create a constant variable in Local scope of the filepath that will be read/written to. Local Const $sFilePath = @ScriptDir & "\Mapping\" & "Config.ini" Local $sFilewrite = 'IGNORE_ERRORS=' & IniWrite($sFilePath, "settings", 'IGNORE_ERRORS', 1 & @CRLF & 'Installer='& $out) $out is generated by another CMD process script that scans the hard drive in order to find the mapping software. But if you know the path won't change I would write it in like below. ;Create a constant variable in Local scope of the filepath that will be read/written to. Local Const $sFilePath = @ScriptDir & "\Mapping\" & "Config.ini" Local $sFilewrite = 'IGNORE_ERRORS=' & IniWrite($sFilePath, "settings", 'IGNORE_ERRORS', 1 & @CRLF & 'Installer=' & "C:\Users\aa2zz6\AppData\Local\ESRI\Desktop10.1\ArcGIS Desktop.exe") .ini file will look like [settings] IGNORE_ERRORS=1 Installer=C:\Users\aa2zz6\AppData\Local\ESRI\Desktop10.1\ArcGIS Desktop.exe Reading file path to CMD Global $Ignore, $Ini, $Installer, $Pid ; Ini Settings file $Ini = @ScriptDir & "\Mapping\" & "Config.ini"" ; Read Ini Setting: IGNORE_ERRORS=0 or IGNORE_ERRORS=1 $Ignore = 'IGNORE_ERRORS=' & IniRead($Ini, "Settings", "IGNORE_ERRORS", 0) ; Read Ini Setting: Installer to run later $Installer = IniRead($Ini, "Settings", "Installer", "") ; If $Installer is something and $Installer exists, then run it. If $Installer And FileExists($Installer) Then $Pid = Run('"' & @ComSpec & '" /c "' & $Installer & '" /v "' & $Ignore & '"', @ScriptDir, @SW_HIDE) ; Check if @error is set. (Use of Exit is optional as used for example) If @error Then Exit 1 ; Wait for process to close ProcessWaitClose($Pid) Else ; Act on condition failure of $Installer If Not $Installer Then Exit 2 If Not FileExists($Installer) Then Exit 3 EndIf Edited November 24, 2016 by aa2zz6 meoit 1
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