aa2zz6

Load program from CMD

4 posts in this topic

#1 ·  Posted (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 by aa2zz6

Share this post


Link to post
Share on other sites



Solved

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by aa2zz6
1 person likes this

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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hello
      How are you
      I have a question, please.
      I've created a window and i need
      when i run the script if it detect an other copy from the same script was runing
       the script close the first copy Automatically and run a new copy
      I want an example to understand it
    • Nareshm
      By Nareshm
      How to repeat my script when my control class does not match ?
       
      My Script : winActivate ( " PS :: Version - 2.2.0.0  - [PS Bill]")                   ControlClick ( "PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]")                   ControlSend(" PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")                   WinActive ("Verification Number Entry ::")                   ControlClick("Next >", "","[NAME:btnNext]") ;if   >>>> Control <<<<  does not match repeat my script, ;if match exit script  

      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
    • Nareshm
      By Nareshm
      Please Somebody Help me i am trying to create new script but, i don't know how to create it.

      I am Creating script like this :
      ; My script here [First Script]
      Check the internet connection, if internet connected then
      ; My Script here [Second Script]
      If internet not connected, wait for connect, after connected run my second script
      If Control id/windows/title matched do nothing and end/exit autoit script
      If Control id/windows/title not matched repeat my first and second script again until control id/windows/tittle not matched

      match with :
      >>>> Window <<<<
      Title:    PS :: Version - 2.8.0.0  - [PS Bill]
      Class:    WindowsForm734a
      Position:    -8, -8
      Size:    1382, 744
      Style:    0x17CD0000
      ExStyle:    0x00050100
      Handle:    0x0000000000130572
      >>>> Control <<<<
      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
       
    • Nareshm
      By Nareshm
      I create message box but i dont know how to add button action when i click it.

      Help for : Add script for Button : Left, Right, Right Finger
      example when i press Left finger button do Case $idNotepad
                      $iPID = WinActivate ( " :PS :: Version - 2.8.0.0  - [eFS Bill]")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:btnReset]", "{esc}")
                              ControlClick ( " :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]")
                              ControlSend(" :DS  - eF:: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "^v")
                              ControlSend(" :DS  - eF :: Version - 2.8.0.0  - [eF Bill]", "", "[NAME:txtrdNo]", "{enter}")
      How to add like above ?
                    
                                                                sorry for my bad english
       
    • nacerbaaziz
      By nacerbaaziz
      Hi friends, I have a question, please.
      I have created a window containing a edit box
      I need to know how to change the keyboard language,
      e.g :
      if a user open the  script  it will be change the keyBord language   in window automatically into English
      I found more examples but didn't work with me .
      Note:  
       I use the windows 10 os
      Please help me .
      thanks in advance to all
      with my Greetings and my appreciation for all users and admins