Sign in to follow this  
Followers 0
TheNorwegianUser

Shellexecute / Run error

3 posts in this topic

#1 ·  Posted (edited)

Okay, so I have a TCP connection set up over some computers, no problem. I recieve the messages without problem, and when I get a specific message over the server, it runs some program. No problem at first. But then, after the whole script has ran for a while, it won't open any program, not even a web page like ShellExecute("www.google.com"). It just returns @error=1. It's nothing wrong with the path, FileExists makes sure of that (Always returns 1). When I then try using Run instead of ShellExecute, I still get an error. Any idea why it just works at first, but then starts to fail every time?

Relevant for opening a specific file:

ShellExecute(@DesktopDir & "\Fireplace.mp4")
If @error Then
    FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  ShellExecute Error: " & @error & " & Extended: " & @extended & @CRLF)
    $Exists=FileExists(@DesktopDir & "\Fireplace.mp4")
    FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Exists: " & $Exists & " & exists error: " & @error & " & Extended: " & @extended & @CRLF);;;;;;;;;;;
    Run(@DesktopDir & "\Fireplace.mp4")
    If @error Then FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Run Bål Error: " & @error & " & Extended: " & @extended & @CRLF)
EndIf

Whole client:

#Include <_AudioEndpointVolume.au3>
#include <Process.au3>
TCPStartup()
OnAutoItExitRegister("Terminate")
$IPAdress="My personal IP..."
$Port= Some IP...
Local $Socket
Connect()

While 1
    Sleep(50)
    Recv()
    If _IsInternetConnected()=False Then Connect(2)
WEnd

Func Recv()
    $Recv=TCPRecv($Socket, 2048)
    If @error>0 Then Connect(@error & "    " & @extended)
    If $Recv="" Then Return
    FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Recieved " & $Recv & @CRLF);;;;;;;;;;;
    $Recv=StringReplace($Recv, @CR, "")
    CheckForAction($Recv)
EndFunc

Func Connect($Conn=0)
    TCPCloseSocket($Socket)
    FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Connection mode " & $Conn & @CRLF);;;;;;;;;;;
    TraySetIcon(@ScriptDir & "\icons\offline.ico")
    Do
        Sleep(1000)
        $Socket=TCPConnect($IPAdress, $Port)
    Until Not @error
    TraySetIcon(@ScriptDir & "\icons\online.ico")
    TCPSend($Socket, "ImMain")
EndFunc

Func CheckForAction($_Recv)
    If $_Recv="vg" Then
        ShellExecute("www.vg.no")
        Return True
    EndIf
    If $_Recv="bål" Or $_Recv="bÃ¥l" Then
        ShellExecute(@DesktopDir & "\Fireplace.mp4")
        If @error Then
            FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  ShellExecute Error: " & @error & " & Extended: " & @extended & @CRLF)
            $Exists=FileExists(@DesktopDir & "\Fireplace.mp4")
            FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Exists: " & $Exists & " & exists error: " & @error & " & Extended: " & @extended & @CRLF);;;;;;;;;;;
            Run(@DesktopDir & "\Fireplace.mp4")
            If @error Then FileWrite(@DesktopDir & "\MultiClientMainLog.txt", @MDAY & "." & @MON & "." & @YEAR & "   " & @HOUR & ":" & @MIN & "  -  Run Bål Error: " & @error & " & Extended: " & @extended & @CRLF)
        EndIf
        Sleep(1000)
        Send("f")
        Return True
    EndIf
    If $_Recv="exit" Then
        Send("{ALTDOWN}{F4}{ALTUP}")
        Return True
    EndIf
    If $_Recv="opp" Then
        Send("{PGUP}")
        Return True
    EndIf
    If $_Recv="ned" Then
        Send("{PGDN}")
        Return True
    EndIf
    If $_Recv="endc" Then
        FileWrite(@TempDir & "\endc.txt", "ok")
        Return True
    EndIf
    If $_Recv="startc" Then
        FileWrite(@TempDir & "\startc.txt", "ok")
        Return True
    EndIf
    If $_Recv="cbål" Or $_Recv="cbÃ¥l" Then
        FileWrite(@TempDir & "\endc.txt", "ok")
        Sleep(3000)
        ShellExecute(@DesktopDir & "\Fireplace.mp4")
        Sleep(1000)
        Send("f")
        Return True
    EndIf
    If StringLeft($_Recv, 3)="cmd" Then
        _RunDOS(StringTrimLeft($_Recv, 4))
        Return True
    EndIf
    If StringLeft($_Recv, 3)="au3" Then
        If FileExists(@TempDir & "\Run.au3") Then FileDelete(@TempDir & "\Run.au3")
        FileWrite(@TempDir & "\Run.au3", StringTrimLeft($_Recv, 4))
        ShellExecute(@TempDir & "\Run.au3")
        Return True
    EndIf
    If Stringleft($_Recv, 10)="set volume" Then
        _SetMasterVolumeLevelScalar(StringTrimLeft($_Recv, 11))
        Return True
    EndIf
    If StringLeft($_Recv, 4)="send" Then
        Send(StringTrimLeft($_Recv, 5))
        Return True
    EndIf
    If StringLeft($_Recv, 4)="www." Then
        ShellExecute($_Recv)
        Return True
    EndIf
    Return False
EndFunc

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then Return SetError(1, 0, False)
    Return $aReturn[0] = 0
EndFunc ;==>_IsInternetConnected

Func Terminate()
    TCPShutdown()
    Exit
EndFunc

 

Edited by TheNorwegianUser

Share this post


Link to post
Share on other sites



Nobody has experienced anything like it? I think it's very odd, at least...

Share this post


Link to post
Share on other sites

No?

It also recieves error 10054 from TcpRecv every 15 minutes of inactivity. No idea why.

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

    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)
       
       
       
       
       
       
    • SkysLastChance
      By SkysLastChance
      I get this error, Whenever I try to find a date. Does anyone have any idea why? I saw some post from 2015, However I would imagine this is fixed by now. @water
      >"J:\Temporary Files\XXXXXXXXX\AutoIt\AutoIt\AutoIt\SciTe\..\autoit3.exe" /ErrorStdOut "C:\Users\XXXXXX\Desktop\Call Report Automation.au3"     "J:\Temporary Files\XXXXXXXX\AutoIt\AutoIt\AutoIt\Include\Excel.au3" (656) : ==> The requested action with this object has failed.: $aResult[$iIndex][1] = $oMatch.Name.Name $aResult[$iIndex][1] = $oMatch^ ERROR >Exit code: 1    Time: 5.791 #include <Excel.au3> Global $sExcelFile1 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)") Global $sExcelFile2 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)") If FileExists($sExcelFile2) Then Global $oExcel2 = _Excel_Open () $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2) EndIF If FileExists($sExcelFile1) Then Global $oExcel1 = _Excel_Open () $oExcel1 = _Excel_BookOpen($oExcel1,$sExcelFile1,Default,Default,"2007") EndIF $oRead = _Excel_RangeRead ($oExcel2,Default,"A2",3) _Excel_RangeWrite ($oExcel1,"Calls Handled",$oRead,"BY7") Sleep (1000) _Excel_RangeFind ($oExcel1,$oRead,"E4:FD92") MsgBox (0,"Test",$oRead) UPDATE:
      If I take out this line it works. By works I mean I don't get the error. :/  However, I need it. I am just confused.
      _Excel_RangeWrite ($oExcel1,"Calls Handled",$oRead,"BY7")  
      UPDATE 2: I also get this error when trying to use the helpfile examples. I have version 3.3.14.2
      \AutoIt\AutoIt\AutoIt\Include\Excel.au3" (670) : ==> The requested action with this object has failed.: $oSheet = $oWorkbook.Sheets($iIndexSheets) $oSheet = $oWorkbook^ ERROR >Exit code: 1 Time: 0.8931  
    • kawliga751
      By kawliga751
      I am attempting to run an Autoit.exe with schtasks every weekday @ 9:05 am.
      I have the below
      C:\>SchTasks /Create /TN "P10Run" /TR "O:\AUTOIT\P40 Run.au3" /SC WEEKLY /D MON, TUE,WED,THU,FRI /ST 09:05:00 SUCCESS: The scheduled task "P10Run" has successfully been created. I also did a "test" run :
      C:\>Schtasks /Run /TN "P10Run SUCCESS: Attempted to run the scheduled task "P10Run". But when I run my query to verify success my "Last Result" seems to indicate that the script did not run:
      C:\>SCHTASKS /QUERY /FO LIST /V /TN "P10RUN" Folder: \ HostName: xxxxxxxxxxxxxxxx TaskName: \P10RUN Next Run Time: N/A Status: Could not start Logon Mode: Interactive only Last Run Time: 6/14/2017 9:08:56 AM Last Result: -2147024894 Author: xxxxxxx Task To Run: O:\AUTOIT\P40 Run.au3 Start In: N/A Comment: N/A Scheduled Task State: Enabled Idle Time: Disabled Power Management: Stop On Battery Mode, No Start On Batterie s Run As User: xxxxxxxxx\xxxxxxxx Delete Task If Not Rescheduled: Enabled Stop Task If Runs X Hours and X Mins: 72:00:00 Schedule: Scheduling data is not available in this f ormat. Schedule Type: Weekly Start Time: 9:05:00 AM Start Date: 6/14/2017 End Date: N/A Days: MON, TUE, WED, THU, FRI Months: Every 1 week(s) Repeat: Every: Disabled Repeat: Until: Time: Disabled Repeat: Until: Duration: Disabled Repeat: Stop If Still Running: Disabled C:\> Is there something missing in my command? Also is there a better way to make sure that the script does in fact sun successfully?
      Thanks In Advance! 
    • SkysLastChance
      By SkysLastChance
      How would I go about writing a IF Then statement if the conrol send fails?
      Run ("Notepad.exe") WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "Edit1", ("Provider Practice Record")) I have been running into lag alot. So my script has been missing input. I would like to be able to have it retry to put in "Provider Practice Record" if it misses. 
      I am assuming  a if then statement is what I need but I am not sure what ControlSend will return if it tries to send to Edit1 and it is not there. 
      Or do I need to just add a timeout? 
       
    • ChipConnJohn
      By ChipConnJohn
      Hello all,
      I'm trying to create a webscrape script using AutoIt.  A non-profit I'm involved with is using GroupSpaces.com and there is no notification to the group when someone posts a new topic to the forum.  I'm including IE.au3

      #include <MsgBoxConstants.au3>
      #include <Array.au3>
      #include <String.au3>
      ; Open Groupspaces.com
      Global $oIE = _IECreate ("http://www.groupspaces.com")
      _IENavigate($oIE,"http://groupspaces.com/MyCrazyTest/forum/")
      ;Grab all the links on the Forum page
      Global $oLinksCategoryPage = _IELinkGetCollection($oIE)
      For $oLink In $oLinksCategoryPage
          Local $oLinkHRef = $oLink.href
          If StringInStr($oLinkHRef,"forum_id") Then
              ;This is a category. Click into it.
              _IENavigate($oIE,$oLinkHRef)
      Sleep(3)
              ;Back out to Category List
              _IEAction($oIE,"back")
          EndIf
      Next
      _IEQuit($oIE)