Sign in to follow this  
Followers 0
Chimaera

Weird Browser Issue

33 posts in this topic

Im running a test to make sure browsers connect properly to the internet like this

If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe')
            If ProcessExists('chrome.exe') Then ProcessClose('chrome.exe')
            If ProcessExists('firefox.exe') Then ProcessClose('firefox.exe')
            Sleep(200)
            ShellExecuteWait('iexplore.exe')
            Sleep(200)
            If FileExists(@ProgramFilesDir & '\Google\Chrome\Application\chrome.exe') Then ShellExecuteWait('chrome.exe')
            Sleep(200)
            If FileExists(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe') Then ShellExecuteWait('firefox.exe')
            Sleep(200)
            If Not ProcessExists('iexplore.exe') Or Not ProcessExists('chrome.exe') Or Not ProcessExists('firefox.exe') Then
                Switch MsgBox($MB_YESNO + $MB_ICONWARNING + $MB_DEFBUTTON2, 'Browsers Check', 'Did All Browsers Work')
                    Case $IDYES
                        GUICtrlSetImage($BrowserIcon, $tick)
                        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Browser', 'REG_SZ', _Date_Time_SystemTimeToDateTimeStr($CuDate))
                    Case $IDNO
                        GUICtrlSetImage($BrowserIcon, $cross)
                        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Browser', 'REG_SZ', 'NotCompleted')
                EndSwitch
            EndIf

But it hangs like a git between 

ShellExecuteWait('iexplore.exe')
            Sleep(200)
            If FileExists(@ProgramFilesDir & '\Google\Chrome\Application\chrome.exe') Then ShellExecuteWait('chrome.exe')

If i reduce it to this

ShellExecuteWait('iexplore.exe')
            Sleep(200)
;~          If FileExists(@ProgramFilesDir & '\Google\Chrome\Application\chrome.exe') Then 
                ShellExecuteWait('chrome.exe')
            Sleep(200)
;~          If FileExists(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe') Then 
                ShellExecuteWait('firefox.exe')

Its instant but then it gives an error that firefox cant be found if its not installed

Any suggestions how to stop this hanging

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only place this would 'hang' is waiting for someone to manually close the IE browser.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

for a start, Chrome spawns more than 1 chrome.exe process which are not all always closes just because the browser is.

And so bearing that in mind, you might want to rethink this line

If ProcessExists('chrome.exe') Then ProcessClose('chrome.exe')

and maybe the others too.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok i see what your saying

I tried this but its not removing them like i thought it should the array display is there but no close

Local $ChromeTest = ProcessList('chrome.exe')
            _ArrayDisplay($ChromeTest)
            If IsArray($ChromeTest) =1 Then
                ConsoleWrite("start remove")
                For $Loop = 1 To $ChromeTest[0]
                    ProcessClose($ChromeTest[$Loop])
                Next
                ConsoleWrite("end remove")
            EndIf

what did i miss?

edit i had #requireadmin on when its off i get this

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
For $Loop = 1 To $ChromeTest[0]
For $Loop = 1 To ^ ERROR

tried this as well

Local $ChromeTest = ProcessList('chrome.exe')
            _ArrayDisplay($ChromeTest)
            If IsArray($ChromeTest) Then
                ConsoleWrite("start remove" & @CRLF)
                For $Loop = 1 To $ChromeTest[0]
                    ProcessClose($ChromeTest[$Loop])
                Next
                ConsoleWrite("end remove" & @CRLF)
            Else
                ConsoleWrite("no remove" & @CRLF)
            EndIf
Edited by Chimaera

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Right after some messing about ive got to this

Local $ChromeTest = ProcessList('chrome.exe')
            _ArrayDisplay($ChromeTest)
            If IsArray($ChromeTest) Then
                For $Loop = 1 To $ChromeTest[1][1]
                    ProcessClose($ChromeTest[$Loop][1])
                Next
            EndIf

this closes all the chrome windows

But ive hit another error after it does

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
ProcessClose($ChromeTest[$Loop][1])
ProcessClose(^ ERROR

Now im guessing that is because it runs out of things to do but shouldnt it just exit after the last one?

EDIT

maybe this

Local $ChromeTest = ProcessList('chrome.exe')
            _ArrayDisplay($ChromeTest)
            If IsArray($ChromeTest) Then
                For $Loop = 1 To $ChromeTest[1][1]
                    Local $test = ProcessClose($ChromeTest[$Loop][1])
                    If $test = 0 Then ExitLoop
                Next
            EndIf

That seems to work

Do you think i should terminate all of the three browsers in a similar fashion?

Edited by Chimaera

Share this post


Link to post
Share on other sites

Are you sure the count is located at $ChromeTest[1][1]? Don't you mean $ChromeTest[0][0]? Plus don't declare variables inside loops, this is a performance bottleneck as AutoIt re-declares on each iteration.

Oh and re-read the help file for ProcessList, as an array is ALWAYS returned so it's pointless checking if it's an array with IsArray() as that will always be true.

Local $aList = ProcessList('chrome.exe')
If $aList[0][0] > 0 Then ; An array is returned and @error is NEVER set, so lets check the count.
    _ArrayDisplay($aList)
    Local $bIsProcessClosed = False ; Declare a variable to hold a boolean.
    For $i = 1 To $aList[0][0]
        $bIsProcessClosed =  ProcessClose($aList[$i][1]) ; In AutoIt 0 or 1 can be considered boolean too. It's like a bit in SQL or in C, where 1 and 0 means true or false.
        If $bIsProcessClosed Then ExitLoop ; Exit the loop.
    Next
EndIf

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I started on [0][0] but it only removed one chrome.exe so i figured it was because it was because the name was the same in the entire array so i swopped to [1][1] which i figured was PID and they were all different

At least thats how i read it $aArray[1][1] = 1st Process ID (PID)

Share this post


Link to post
Share on other sites

Is there an issue now?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Great. Just look at the code and match with what the help file says to further enforce understanding.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

No disrespect whatsoever. I was just fixing the code you provided and was in no way coming up with a better solution.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Lol i thought i was doing so well there to get as far as i did then John owns us on the end :)

One small thought on While/Wend if i may

It would never enter my head to use that like John did i've always thought it was only there just for the gui and buttons to make it work.

I remember years ago trying 2 of them in a script and it got in a right mess so i left it holding the Gui together and just assumed that was the only way to use it

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

If you take If $bIsProcessClosed Then ExitLoop out of that snippet (translated from your version) then it's less processor heavy compared to JohnOne's version. As ProcessExists() can be a bottleneck on occasions, just asked BrewManNH.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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
Sign in to follow this  
Followers 0

  • Similar Content

    • Simpel
      By Simpel
      Hi.
      Local $sPDFtk = FileGetShortName(@ScriptDir & "\pdftk.exe") Local $sInputPDF = FileGetShortName(@ScriptDir & "\Prodis_Test.pdf") Local $sSig_1 = FileGetShortName(@ScriptDir & "\Sig_1.pdf") Local $sTempPDF = FileGetShortName(@ScriptDir & "\Prodis_Test_TEMP.pdf") $iSuccess = ShellExecuteWait($sPDFtk, $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF, "", "", @SW_HIDE) @ScriptDir is "H:\_Conrad lokal\Downloads\AutoIt3\_COX". As you can see there is a space in the path.
      I know that ShellExecuteWait is working with FileGetShortName at the filename. It seems to me that I can't pass the parameters that way. But without FileGetShortName it's not working too.
      Ideas? Regards, Conrad
    • Mbee
      By Mbee
      I'm having a problem executing a command line (with many parameters) from within my script using ShellExecuteWait().  As a debug step, my script outputs the generated cmd line and parameters to a temp text file. If I start a cmd window and cut and paste the cmd from this temp file, it works perfectly.  If, however, I call ShellExecuteWait() within the script, the tool I'm running (mkvmerge.exe) always returns error code 2 (invalid cmd line).
      Note that mkvmerge requires a strangely "escaped" parameter list; e.g...
      "C:\Program Files\MKVToolNix\mkvmerge.exe" --output ^"L:/Path1/OutVid.mkv^" --no-subtitles --language 0:eng --default-track 0:yes --compression 0:none --language 1:eng --default-track 1:yes --compression 1:none ^"^(^" ^"L:/Path2/SrcVid.mkv^" ^"^)^" As you can see, mkvmerge mandates that backslashes in paths be replaced with forward-slashes, that quote marks be "escaped" by preceding them with "^" (as well as parentheses), etc.  I'm pretty sure this weirdness is required because mkvmerge was designed for non-Windows OSes (or something like that).
      Is that part of the problem, do you think?
      Under Windows, do any of the quote marks need to be doubled (i.e, should it be ^""L:/Path1/OutVid.mkv^"")?  How about the slashes in the path names (i.e., should it be ^"L://Path1//OutVid.mkv^")?
       
      Finally, am I correct to assume that I must use ShellExecuteWait() because one cannot pass command line parameters with RunWait()?  If not, is there any benefit of using one over the other?
       
      Thanks a great deal for your consideration and assistance!
    • AntonioGNAL
      By AntonioGNAL
      Hi guys,
      I've been trying to create a registry key export for a while, but i'm hitting my head against a wall here.
      I've tried a huge amount of combinations for both:
      ShellExecuteWait & RunWait commands, but they never complete the task.
      ;This is the reg key Global $targetHistory = "HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History" RegeditTH($logHandler, $regBackup, $targetHistory) Func RegeditTH($logHandler, $regBackup, $targetHistory) Local $THRegBkup = $regBackup & "ExportTH.bat" Local $THRegHandler Local $removeFile _FileWriteLog($logHandler, "INFORMATION: ExportTH.bat storage directory = " & $regBackup & "." & @CRLF) ; Create a file to write registry keys to. If Not _FileCreate($THRegBkup) Then ; Error flags: ; 1 - Error opening specified file ; 2 - File could not be written to ; [OPTIONAL] Display a pop-up message for notification, error creating the file ;MsgBox($MB_SYSTEMMODAL, "Error", " Error reating reg file. Error Code:" & @error & ".") _FileWriteLog($logHandler, "WARNING: Registry export file not created." & @CRLF) Else $THRegHandler = FileOpen ($THRegBkup ,$FO_APPEND) If $THRegHandler <> -1 Then _FileWriteLog($logHandler, "INFORMATION: Performing registry backup for Target History keys." & @CRLF) FileWrite($THRegHandler, "@echo off" & @CRLF) ;FileWrite($THRegHandler, "regedit.exe /e " & $regBackup & "TargetHistory.reg " & '"HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History"' & @CRLF) FileWrite($THRegHandler, "Reg export " & '"HKEY_CURRENT_USER\Software\Hewlett-Packard\HP Print Settings\Ubicación predeterminada\Target History" ' & $regBackup & "TargetHistory.reg " & "/y" & @CRLF) FileWrite($THRegHandler, "dir " & $regBackup & @CRLF) FileWrite($THRegHandler, "dir " & $regBackup & " >> " & $regBackup & "dir.txt" & @CRLF) FileWrite($THRegHandler, "pause" & @CRLF) FileWrite($THRegHandler, "exit /B" & @CRLF) FileWrite($THRegHandler, "exit" & @CRLF) FileClose($THRegHandler) ;RunWait(@ComSpec & " /k " & "regedit.exe /e " & $regBackup & "TargetHistory2.reg " & $targetHistory) ;ShellExecuteWait(@ComSpec , "/k regedit.exe /e " & $regBackup & "TargetHistory.reg " & $targetHistory) ;ShellExecuteWait(@ComSpec & " /c " & $THRegBkup, @SW_HIDE) RunWait(@ComSpec & " /c " & $THRegBkup) ; Error Flag is set to non-zero in case of failure If @error <> 0 Then _FileWriteLog($logHandler, "ERROR: Registry export failed." & @CRLF) Else _FileWriteLog($logHandler, "WARNING: ExportTH.bat file could not be opened." & @CRLF) EndIf $removeFile = FileDelete($THRegBkup) If $removeFile Then _FileWriteLog($logHandler, "INFORMATION: File " & $THRegBkup & " deleted." Else _FileWriteLog($logHandler, "WARNING: File " & $THRegBkup & " not deleted or it does not exist." EndIf EndIf ; Close the handle returned by FileOpen. FileClose($THRegHandler) EndFunc This is the function i'm using for the call.
      Since i was not going anywhere with the AutoIt direct executions, i even tried creating a bat/cmd file with the command for a reg export to create the reg file i needed. However, even running the bat file is not working for me. I mean, the bat is executed, as you can see i created a couple of "dir" commands to be prompted and sent to a file. And they are showing up, but the registry export is never being executed.
      The best i could get was a message saying it was impossible to locate the key, but i know with 100% certainty the key exists in that path (because i'm creating and deleting it all the time).
      Can anyone point out any possible mistakes?
      Here you can see the error message in the CMD prompt:

      Thanks!
    • Kevinsyel
      By Kevinsyel
      I was wondering if there are any developers out there who are having issues running AutoIT code on the latest revision of Win8?
      I recently (about 4 months ago) wrote an auto-installer that pulled tools from a server and ran an auto install of each tool on systems.
      This worked fine for revisions 8250, 8375 and 8400. However, when Win8 revision 8441 came around, I noticed some issues running some installers.
      Now with the newest revision, 8520, it seems that FileCopy, DirCopy, ShellExecute, ShellExecuteWait, Run, and RunWait are all either locking up, or just failing to run.

      The steps I take are:

      Read from a cfg file the path of the installer, and any installer arguments
      download installer from path
      use ShellExecuteWait on installer with arguments

      In the past, I've had no problems with this same exact code. UAC is off, #RequireAdmin is set, application is run as administrator, and even powershell is set to "Set-ExecutionPolicy UnRestricted"

      Has anybody else had this problem? Anybody have workarounds?