Jump to content

mihaijulien

Active Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by mihaijulien

  1. Ok, so I found where the problem is. When running the .au3 script, there are actually more parameters. I used _ArrayDisplay() method to see what's stored in $CmdLine. Here's for the .au3: And here's for the .exe: At the beginning of my script, I have these 2 variables: Local $hWnd = "MyApp " & $CmdLine[2] &" Setup" Local $installer = "myapp-win-installer-" & $CmdLine[2] &".msi" For the script, they are ok, but for the .exe, they aren't anymore.
  2. Ok, so using the script above, I get the following error, no matter what: 175628_ScriptLine-8: ! Not enter comnand line! I'm not really sure if this is correct, xCmdLine[0] can't be 0 no matter what, as far as I get how things work with command line parameters. Also, when using the above code, the script works fine when running the .au3 with the parameter, but the MsgBox pops when launching the .exe.
  3. Sorry I didn't reply, but yes, I tried my scripts with your suggestions (changing the default $CmdLine to $sCmdLine.
  4. Works perfectly when running the .au3, after I compile it (x64) it no longer works, same error. (but this time the error is on Line 17). :/
  5. Well, I open a cmd and I type "InstallScript.au3 5.0". I launch the executable in the same way: "InstallScript.exe 5.0". The first works, the second doesn't. I'm still trying to figure out what might be the problem.
  6. The script works just fine when it isn't compiled. When launching the .exe, I have the error from the attached file. It's pretty strange.
  7. Hello, I don't think it's relevant what it's in the UDF folder that I included, but here it is attached. The script above works just fine when not compiled. UDF.7z
  8. Here is the code: #RequireAdmin #include <FileConstants.au3> #include <WinAPIShPath.au3> #include "UDF\log4a.au3" Opt("WinTitleMatchMode",2) Global $defaultLocation = "C:\Program Files\MyApp\" & $CmdLine Global $CmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw) Install() $processes = _MyProcessList("MyApp") If ProcessExists($processes[1]) Then LogInfo("App service started succesfully") EndIf _ProcessCloseEx($processes[1]) ;kill App & child processes Func Install() Local $hWnd = "MyApp " & $CmdLine[2] &" Setup" Local $installer = "myapp-win-installer-" & $CmdLine[2] &".msi" ShellExecute($installer,"",@ScriptDir & "\installers") If @error Then LogInfo("Error when starting the installer") Return EndIf While Not ControlCommand($hWnd,"","[Text:&Next >]", "IsEnabled",'') Sleep(500) ;if the app is already installed, close the install wizard If ControlGetText($hWnd,"","[Text:Remove Installation]") Then LogError("Error: MyApp is already installed") Sleep(1000) WinClose($hWnd) Return EndIf WEnd ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ;first Next ;1572 Local $counter = 0 For $counter = 0 to 1 Send("{TAB}") Sleep(100) Next Send("{UP}") ;accept the terms in the License Agreement ;57 Sleep(100) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ; Next ;1572 Sleep(500) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:5]") ; uncheck app start ;3281 Sleep(500) ;install the app at the default location ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ; Next ;1572 Sleep(500) If WinExists($hWnd, "Port Conflict Found") Then ControlClick($hWnd, "","[CLASS:Button; INSTANCE:4]") Sleep(500) ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:1]") EndIf WinWaitActive("MyApp Test") ControlClick("MyApp Test","","[CLASS:Button; INSTANCE:1]") ;Ok on the test ; wait the install successful UI While 1 $var = ControlGetText($hWnd, "", "[Text:&Finish]") If $var == "&Finish" Then ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ;Finish ExitLoop EndIf Sleep(1000) WEnd EndFunc ;kill processes Func _ProcessCloseEx($sPID) If IsString($sPID) Then $sPID = ProcessExists($sPID) If Not $sPID Then Return SetError(1, 0, 0) Return Run(@ComSpec & " /c taskkill /F /PID " & $sPID & " /T", @SystemDir, @SW_HIDE) EndFunc ;retrieve processes using partial name string as parameter Func _MyProcessList($str) Local $alist = ProcessList(), $ret For $1 = 0 To UBound($alist) - 1 If StringInStr($alist[$1][0], $str) Then $ret &= $alist[$1][0] & '|' Next Return StringSplit(StringTrimRight($ret, 1), '|') EndFunc The .au3 works fine.
  9. Hello, I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns the following error: Error: array variable has incorrect number of subscripts or subscript dimension range exceeded
  10. That was exactly what I was looking for. I thought that there was something built-in but those 2 functions are the way to do it. Thank you.
  11. Is there a way to retrieve a ProcessList("[name]") having as parameter only a part of the name?
  12. Ok, so I found a workaround. Instead of: ControlSetText($hWnd,$defaultLocation,"[CLASS:Edit; INSTANCE:1]", $alternateLocation) I used: Send("D:\MyApp")
  13. So, I am stopping the script after it sends the alternate location to the edit box and from that point I continue the installation manually. #requireadmin #include <FileConstants.au3> #include <WinApi.au3> Opt("WinTitleMatchMode",2) Global $defaultLocation = "C:\Program Files\MyApp" Global $alternateLocation = "D:\MyApp" InstallG2() Func InstallG2() Local $hWnd = "Install Wizard" Local $dir = DirCreate($alternateLocation) ;create alternate location folder ShellExecute("win-installer-5.6.0.msi","",@ScriptDir & "\c2") While Not ControlCommand($hWnd,"","[Text:&Next >]", "IsEnabled",'') Sleep(500) WEnd ;if the app is already installed, close the install wizard If ControlGetText($hWnd,"","[Text:Remove Installation]") Then WinClose($hWnd) Return Else ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ;first Next ;1572 Local $counter = 0 For $counter = 0 to 1 Send("{TAB}") Sleep(100) Next Send("{UP}") ;accept the terms in the License Agreement ;57 Sleep(100) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ; Next ;1572 Sleep(500) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:5]") ; uncheck start Sleep(500) ;install in a different location _selectEdit($hWnd) ControlSetText($hWnd,$defaultLocation,"[CLASS:Edit; INSTANCE:1]", $alternateLocation) Sleep(100000000) ; <----------- I stop the script here EndFunc The result is the same, the app install in the default location at C:\Program Files\MyApp. That's pretty strange.
  14. Hello, I need to automate the install process of an application. Everything works fine when using the default configuration. But there's a problem when changing the default install location. I have the following code: #requireadmin #include <FileConstants.au3> #include <WinApi.au3> Opt("WinTitleMatchMode",2) Global $defaultLocation = "C:\Program Files\MyApp" Global $alternateLocation = "D:\MyApp" InstallG2() Func InstallG2() Local $hWnd = "Install Wizard" Local $dir = DirCreate($alternateLocation) ;create alternate location folder ShellExecute("win-installer-5.6.0.msi","",@ScriptDir & "\c2") While Not ControlCommand($hWnd,"","[Text:&Next >]", "IsEnabled",'') Sleep(500) WEnd ;if the app is already installed, close the install wizard If ControlGetText($hWnd,"","[Text:Remove Installation]") Then WinClose($hWnd) Return Else ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ;first Next ;1572 Local $counter = 0 For $counter = 0 to 1 Send("{TAB}") Sleep(100) Next Send("{UP}") ;accept the terms in the License Agreement ;57 Sleep(100) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ; Next ;1572 Sleep(500) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:5]") ; uncheck start Sleep(500) ;install in a different location _selectEdit($hWnd) ControlSetText($hWnd,$defaultLocation,"[CLASS:Edit; INSTANCE:1]", $alternateLocation) Sleep(1000) ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ; Next ;1572 If ControlGetText("Error","","[CLASS:Button; INSTANCE:1]") Then Exit EndIf ; wait the install successful UI While 1 $var = ControlGetText($hWnd, "", "[Text:&Finish]") If $var == "&Finish" Then ControlClick($hWnd,"","[CLASS:Button; INSTANCE:1]") ;Finish ExitLoop EndIf Sleep(1000) WEnd EndIf EndFunc ; select the edit text box when changing the install location Func _selectEdit($hWnd) $hWnd = _WinAPI_GetFocus() $class = _WinAPI_GetClassName($hWnd) If $class = 'Edit' Then _GUICtrlEdit_SetSel($hWnd, 0, -1) EndFunc The above code doesn't work, when the installing process reaches the step for choosing the install location, it throws an error "Path already exists". If I comment this line: ;Local $dir = DirCreate($alternateLocation) then the app installs in the default location, even though I change the install location. Any ideas what could be wrong or any workaround?
  15. How do I delete the post?
  16. I have something like this: Func MyFunction() If condition Then doSomething Else exitFunction EndIf EndFunc How can I exit the function inside the If Else condition?
  17. Thank you. That was what I was looking for.
  18. Hello, I have the following piece of code: RunWait(@ComSpec & " /c" & $cmd) Sleep(1000) If WinExists("Windows Installer") Then ControlClick("Windows Installer", "","[CLASS:Button; INSTANCE:1]") EndIf It supposed to start an uninstall process, and then when the popup "Are you sure you want to uninstall?" it should click on the Yes button. The problem is that the script stops at this point. Nothing ever happens. Any ideas what it could be?
  19. Indeed, that was the problem. Thank you.
  20. Hello, I'm trying to automate the installer process of an application. I currently have this following code: Start() Func Start() ShellExecuteWait(@ScriptDir & "\installer.msi") Local $hWnd = WinWait("[CLASS:MsiDialogCloseClass]",5) ;WinClose($hWnd) ControlClick("Installer Information", "","[CLASS:Button; INSTANCE:1]") ;Send("{ENTER}") EndFunc This function should only start the installer and press an Ok button of a popup window (or just close it). I tried with ControlClick() , Send() and WinClose() functions but the script only starts the installer. Can't figure out why it doesn't press that button/close the window.
×
×
  • Create New...