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

    • 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)
    • AnonymousX
      By AnonymousX
      Hello,
      What command would I use to open the following folder directories for:
      Computer/This PC (windows 7/Windows 10)
      Libraries\documents
      Libraries\Pictures
      I know:
       Run("Explorer.exe " & $filepath) ShellExecute($filepath) can be used to open folder locations when you type in the full directory such as "C:\Users\%username%\Documents" but I'm trying to figure out how to use these windows short paths. 
      Thanks,
    • StMaSi
      By StMaSi
      I'm attempting to code a Run or RunWait command that is a little on the long side and contains multiple sets of embedded quotes (as it would be issued from a CMD prompt), but can't for the life of me figure out the containing quotes as pertains to AutoIt. Here's the one-line command as it would be issued via a CMD prompt...
      "\\AppServ\G$\Connectivity\Clients\Citrix\Receiver\14.5.0.10018\CitrixReceiver.exe" ADDLOCAL="ReceiverInside,ICA_Client,WebHelper,SSON,AM,SELFSERVICE,USB,DesktopViewer,Flash,Vd3d" ALLOWADDSTORE=A ALLOWSAVEPWD=A ENABLEPRELAUNCH=Y ENABLE_SSON=Yes STORE0="AppStore;https://receiver.domain.net/Citrix/Apps/discovery;on;AppStore" /EnableCEIP=false /includeSSON /noreboot /silent I've tried so many different combinations of surrounding quotes with Run and RunWait, I just don't understand why it's this difficult to get past this.
      Can anyone assist with this?
      Thank you.