Popular Post BinaryBrother Posted December 30, 2024 Popular Post Posted December 30, 2024 (edited) Here it is. _RustDesk_isInstalled() ; Tells whether RustDesk is installed. _RustDesk_GetLocalVersion() ; Gets installed version _RustDesk_GetLatestVersion() ; Check github tags for latest version number. _RustDesk_Deploy() ; Auto pulls from current online version. _RustDesk_SetPassword() ; Sets the RustDesk password for the client _RustDesk_GetID() ; Returns the RustDesk Client ID _RustDesk_Start() ; Starts the existing RustDesk environment _RustDesk_Config() ; Confguration hash for custom relays _RustDesk_InstallService() ; Mainly for internal use. expandcollapse popup#include "UDFs\RustDesk.au3" #Region ##### OPTIONS ##### Opt("MustDeclareVars", 1) Opt("TrayIconHide", 1) #EndRegion ##### OPTIONS ##### #Region ##### ENTRY POINT ##### _Debug(">> MainThread:: Initializing... <<") Local $sID Local $sPassword = "1234567890" Local $sConfig = "ASFSA213444234TEST==" ; Not required If Not _RustDesk_isInstalled() Or $g_RustDesk_CurrentVersion <> $g_RustDesk_LatestVersion Then _RustDesk_Deploy() If @error Then _Error(@error) Else _RustDesk_Start() If @error Then _Error(@error) EndIf _RustDesk_Config($sConfig) $sID = _RustDesk_GetID() If @error Then _Error(@error) _RustDesk_SetPassword($sPassword) If @error Then _Error(@error) _Debug(">> MainThread:: Backend RustDesk Install Finished!") #EndRegion ##### ENTRY POINT ##### #Region UDF Func _Error($pError) Local $sSupport_Info = "Please call BLAH INC. for support!" Local $sAppName = "RustDesk" Switch $pError Case 1 _Debug("!> ERROR: _Download() Failed to get INetGet HNDL! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 2 _Debug("!> ERROR: _Download() Can't get filesize to predict progress! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 3 _Debug("!> ERROR: _Download() interrupted! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 4 _Debug("!> ERROR: _GetRemoteVersion() Failed to retrieve TAGS page! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Could not find latest version of Rust Desk!" & @CRLF & $sSupport_Info) Case 5 _Debug("!> ERROR: _GetRemoteVersion() RegEx failed to find version number! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Could not find latest version of Rust Desk!" & @CRLF & $sSupport_Info) Case 6 _Debug("!> ERROR: _Run(): Failed to run! No Args. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to Launch Application!" & @CRLF & $sSupport_Info) Case 7 _Debug("!> ERROR: _Run(): Failed to run! With Args. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to Launch Application!" & @CRLF & $sSupport_Info) Case 8 _Debug("!> ERROR: _Set_RustDesk_Password(): Failed set RustDesk Password! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to set RustDesk Password!" & @CRLF & $sSupport_Info) Case 9 _Debug("!> ERROR: _Get_RustDesk_ID(): Failed to acquire RustDesk ID. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to get RustDeskID!" & @CRLF & $sSupport_Info) Case 10 _Debug("!> ERROR: _Deploy_RustDesk(): TIMEOUTs waiting for service RUNNING. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to properly launch RustDesk!" & @CRLF & $sSupport_Info) EndSwitch Exit EndFunc ;==>_Error #EndRegion Update: 1/10/25 - Added _RustDesk_Config() for those who need to configure a custom relay. RustDesk.au3 Edited January 10 by BinaryBrother Update Danyfirex, dmob, argumentum and 2 others 3 2 SIGNATURE_0X800007D NOT FOUND
BinaryBrother Posted December 30, 2024 Author Posted December 30, 2024 It needs to be slightly modified to use the MSI, instead of the EXE installer. The MSI handles firing up the service, instead of having to do it manually. This UDF is close enough for you guys to modify and use. I won't be maintaining unless interest is expressed. SIGNATURE_0X800007D NOT FOUND
argumentum Posted December 30, 2024 Posted December 30, 2024 1 hour ago, BinaryBrother said: I won't be maintaining unless interest is expressed. Global $g_RustDesk_CallForSupportStr = "Please call (XXX)-XXX-XXXX for support!" Func _RustDesk_CallForSupportStr($sStr = Default) If $sStr <> Default Then $g_RustDesk_CallForSupportStr = $sStr Return $g_RustDesk_CallForSupportStr EndFunc ;==>_RustDesk_CallForSupportStr That is a better idea. Maybe go the extra mile and add a function just for that. Making a UDF is a pain. In my case because I can hear the complains in my head and change the UDF to appease those in my mind. Shut up already !, am typing ! 🤪 But those ideas don't come to mind beforehand. Only after some exposure is that they pop-up. In either case, if you maintain it, you'll be a better coder. Even if no one uses it, so, thanks for sharing and do keep it up. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
BinaryBrother Posted January 1 Author Posted January 1 Yeah, I thought it was a pretty good foundation. I made a quick sc.exe "Service Control" wrapper, but if you use the MSI you don't need it. And yeah, I could definitely throw the repeated text into a variable. argumentum 1 SIGNATURE_0X800007D NOT FOUND
BinaryBrother Posted January 2 Author Posted January 2 (edited) I'm taking your advice, and maintaining, but I don't have the time to de-customize every aspect. Uploads on main post: Updated. Removed in-post static code. Edited January 2 by BinaryBrother argumentum 1 SIGNATURE_0X800007D NOT FOUND
Trong Posted January 3 Posted January 3 (edited) I created the relay server myself and installed RustDesk using the auto install script via ps. It seems your UDF is not detecting it. Edited January 3 by Trong https://vnc.my/WindowsAgentAIOInstall.ps1 Regards,
BinaryBrother Posted January 5 Author Posted January 5 It's looking for a registry key to determine the local version, as per the PowerShell script provided, I used... Global $g_RustDesk_RegPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk" Global $g_RustDesk_RegKey = "Version" What value do you have at that location? SIGNATURE_0X800007D NOT FOUND
Solution BinaryBrother Posted January 6 Author Solution Posted January 6 (edited) I had a similar problem running the script under x86. Make sure you're running x64 through scite, or compile the scripts for x64 support. I'm gonna update the UDF one more time, I have to remove all my personal info so it'll take me a second. Edit: I shared my current working version in the first post. Just make sure you're running under an x64 atmosphere. You'll have to remove my personalizations, I don't have time right now but I still want to see you get this working. To be clear, this is dirty. You'll have to do some housekeeping. Also, you can try changing HKLM to HKLM64, if you're intent on running in an x86 environment. And Kudos to you for accurately describing your issue with screenshots. Final Edit: I did not account for using custom relays in this UDF. I only intended to Install/Update RustDesk and return the ID and Pass back to my server. And in my defense, the provided PowerShell script was horrid. Using sleeps to wait for services to start, etc. At least, my conversion actually checks for a running service, and attempts to start it if found or install it if it's missing. There's NO error checking in that PS script. Anywho... I've patched this together with a bottle of brandy and just got back from the ER over bronchitis. Ask me specifics and I'll try to detail things a bit better, but for now I'm just giving you what I have. I cleaned it up and fixed the first post. Edited January 8 by BinaryBrother Warnings SIGNATURE_0X800007D NOT FOUND
BinaryBrother Posted January 8 Author Posted January 8 (edited) Alright, I decided to make a proper UDF. Error handling is moved to user context or the main thread. Misc UDFs are now included within the primary RustDesk.au3 and x86 builds are now supported. I will humbly accept advice, I know it needs some work. The Service Control portion is cringe. Edited January 8 by BinaryBrother SIGNATURE_0X800007D NOT FOUND
BinaryBrother Posted January 10 Author Posted January 10 (edited) Re-wrote sections involving the Service Control. The service is critical, because RustDesk does not provide an interface for the --get-id and --set-password routines without it. Added Service Control Timeout params in some of the functions. I tested the MSI on Windows 10 and Windows 11 through a virtual environment and found that in almost all instances, if the MSI is deployed, the service is immediately installed. If you install the EXE version, it doesn't init its-own service. Anywho, I just completed a slight overhaul. The new src can be found on the first thread. It has been minimally tested. I've began adding support for those configuration hashes, but since I don't need that functionality progress will be slow. Update: I keep saying I'm not gonna work on it much, but I can't help it. I added support for Config Hashes for configuring custom relays. Untested. Working! Edited January 11 by BinaryBrother SIGNATURE_0X800007D NOT FOUND
BinaryBrother Posted January 11 Author Posted January 11 (edited) Rust Desk is killing me... Sometimes the MSI starts the service, but sometimes it doesn't. I can uninstall and reinstall several times in a row and the service will fail to start like 20% of the time. Then... Half the time STDOUT gets stuck in the primary thread (Returning Flutter info), when I try to use RustDesk's CLI for getting the ID, installing the service, or setting the password. I only switched to using the MSI, because it handles service creation and starting automatically. Installing the EXE has the same STDOUT sinkhole, but rarely handles the service bit. RustDesk has bugs, when it comes to CLI, that I'm having to work-around with hacks (timeouts) or by not even getting the input and just firing the command. This UDF works, but I don't like those two bugs. 1.) RustDesk CLI likes to get stuck on the main thread with STDOUT when passing commands. (All I can do is timeout or avoid ShellExecuteWait, RunWait, and also avoid reading STDOUT. 2.) The Service has to be manually initiated half the time. (Which I've mostly fixed) Wish somebody would give it a look and suggest some revision. Even if I use timeouts for reading the STDOUT, when the "sinkhole" happens, it doesn't return useful data. I suppose with the service creations, I could go with the following logic. If _RustDesk_isRunning() And Not _RustDesk_Service_isInstalled() Then manually use SC to install the service, rather than getting trapped in an STDOUT sinkhole using the RustDesk CLI. Okay, I can do that... Then I'd just need to figure out why I'm getting stuck in STDOUT sinkholes for the other commands that require the use of the RustDesk CLI. Maybe RustDesk has to be running before using the CLI? I'll experiment more with checking if the process is running yet. Edit: The "sinkholes" happen with CMD, "RustDesk.exe --install-service | more" too. There's no regular output, which is strange to me. More has to be used to capture the output. AutoIt can see the STDOUT stream, but CMD on Windows cannot, without piping the output to more. Edited January 11 by BinaryBrother SIGNATURE_0X800007D NOT FOUND
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now