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

    • 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.
    • WoodGrain
      By WoodGrain
      Hi guys,
      This is probably an obvious one, but I really don't use this command at all so am hoping you can spot my mistake.
      I'm running a powershell script on a schedule with the following script in a function, the function is being called in a loop, but the console process is not closing in the background and I end up with a bunch of console windows running in the background:
      Run(@comspec & ' /k PowerShell.exe -STA -NonInteractive -ExecutionPolicy ByPass -Command "& ''Z:\Powershell\365\GetNextDetails.ps1'' "', "", @SW_HIDE) Thanks!
    • knuxfighter
      By knuxfighter
      Hello. I've been working with Imagesearch library lately and it did a good work, although I moved to a new PC and didn't copy the old files with me so I downloaded the Imagesearch from the following post
       hoping that it will work. It doesn't though. First time I when I use (run as subscript to my code) the Imagesearch.au3, Scite finds errors (missing spaces). Ctrl+T (scite tidy) fixes these missing spaces but the script returns the following error on every run after:
      _ImageSearch('search.bmp', 0, $x, $y, 0) outputs
       
      "C:\Users\Knuckles\Desktop\AutoIt\include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: If $result[0] = "0" Then Return 0 If $result^ ERROR no matter if I put the searched bmp in the script folder or folder img in the script directory. Also, it doesn't matter if the searched image on screen or not, it returns the same.

      Can you provide me any help please? I remember having these problems 2 years ago when I first met the imagesearch library also (I fixed it somehow though in that time). Seems nothing changed.

      Using this version posted in the following post gives the same error:
      Also I run windows 10 64bit and I have no shell options for script editing, running as x86 or whatever as I used to have on windows xp/7. I went through some steps like deleting a key in registry and I even reinstalled autoit and scite but that only resulted to au3 as unrecognized file format and not in getting back the menus and the icon on au3 files. Any thoughts on this?

      Edit: Installing 64-bit AutoIt and using 64bit ImageSearch is no change.
      code.au3

      FOUND WORKING: http://www.codebot.de/index.php/Thread/12713-Imagesearch-au3-funktioniert-nicht/
       but why is this one working and the original aren't? :(