Shawn Hall Posted September 13, 2018 Posted September 13, 2018 (edited) This isn't "just another request for a Synergy Portable" build. This is a solution. I was sick of installing Synergy (v1) on client computers just so I could use Synergy on them for a couple hours, so I finally built a script to collect the relevant Windows binaries and data to properly run Synergy as a portable...on Windows. It works great. Tested with Synergy 1.10.1. Download the file on one of your Synergy Client devices. I haven't tested it as a server. It might work (definitely will with a bit of tweaking), but I have no current need for that. It's a batch file so change the extension from txt to bat. Put it in the folder where you want Synergy Portable to be located (such as "j:\SynergyPortable"). Then run it elevated (this is important!). Elevation is required in order to successfully collect files from the Program Files directory. Review the warning. If everything is okay, and you didn't, for example, download it directly to your desktop and run it, then press a key. It'll collect the binaries from ProgramFiles\Synergy, then parse the registry for the specific service command, then collect the data files from the appdata folder. Finally, it'll create a new batch file named Synergy-Portable.bat that will execute the Synergy Client using relative path information. You will probably want to edit the Synergy-Portable.bat to change the device name from whatever it was on the original Synergy Client machine. Download it here or copy the script below: @ECHO OFF ::'=========================================================== :: Make-Synergy-Portable.bat ::'=========================================================== :: This will collect the relevant files from an existing :: Synergy v1 installation to create a working portable. :: Run this ELEVATED from where you want your portable :: synergy to be located, such as "J:\SynergyPortable" ::'=========================================================== ECHO. ECHO.::: WARNING^! ::: ECHO. ECHO.This will collect the relevant files from an existing ECHO.Synergy v1 installation to create a working portable. ECHO.Run this ELEVATED from where you want your portable ECHO.synergy to be located, such as "J:\SynergyPortable" ECHO. ECHO.Note: Elevation is required in order to successfully copy ECHO. files from the Program Files directory. ECHO. ECHO.THIS is the folder where everything is going to be placed: ECHO. %~dp0% ECHO.If that's okay, continue. Otherwise, close this window. ECHO. PAUSE ECHO. ECHO. ECHO.Copying Synergy binaries robocopy "%ProgramFiles%\Synergy" "%~dp0%" /r:1 /w:1 /e /zb ECHO.Parsing Registry for Synergy settings FOR /F "tokens=1,2*" %%a IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Synergy" /v Command') DO SET syncmd=%%c FOR /F usebackq^ tokens^=1^,2^,3^,^*^ delims^=^" %%a IN ('%syncmd%') DO ( SET "synopt=%%b" SET "syndata=%%c" SET "synserver=%%d" ) ECHO. ECHO. ECHO.Collecting Synergy Data ^(such as certificate and fingerprints^) robocopy "%syndata%\Synergy" "%~dp0%\Synergy" /r:1 /w:1 /e /zb ECHO. ECHO. ECHO.Current Synergy command is: ECHO. %syncmd% ECHO. ECHO. ECHO.New Synergy command is: ECHO. "synergyc.exe" %synopt% "%%CD%%" %synserver% ECHO. ECHO. ECHO.Creating Synergy-Portable.bat ECHO."synergyc.exe" %synopt% "%%CD%%" %synserver% 1>%~dp0%\Synergy-Portable.bat SET syncmd= SET synopt= SET syndata= SET synserver= ECHO. ECHO. ECHO.All done. ECHO. ECHO.1^) Eject the %~d0% drive ECHO.2^) Plug it into another device ECHO.3^) Run "Synergy-Portable.bat" ECHO. ECHO.PS: ECHO. You might also want to open Synergy-Portable.bat and change the device name and/or logging level. ECHO. You can use "synergyc --help" to discover available options. ECHO. PAUSE Edited September 13, 2018 by Shawn Hall added a pause at the end Quote
jml Posted September 13, 2018 Posted September 13, 2018 Nice Windows solution!!!!!! Great work. Wonder if something similar's possible for 2.x? Quote
Shawn Hall Posted September 14, 2018 Author Posted September 14, 2018 I doubt it. I believe that the v2 branch uses unique device IDs that would (should?) make it fail to run without authenticating the new device to the cloud service. Once the offline-only feature is released it'll probably be possible though. Quote
Noam Liran Posted September 18, 2018 Posted September 18, 2018 Hey @Shawn Hall, hope you can help here... I tried with both the 32bit and 64bit versions and getting the following error(s) below. I did run this from elevated command prompts. the "1" folder is created on the USB thumb drive, but none of the files (other than the synergy-portable.bat) are moved/created. E:\>dir Volume in drive E is Untitled Volume Serial Number is 3A2B-47CA Directory of E:\ 09/18/2018 10:28 AM 2,291 make_portable.bat 1 File(s) 2,291 bytes 0 Dir(s) 123,004,649,472 bytes free E:\>make_portable.bat ::: WARNING! ::: This will collect the relevant files from an existing Synergy v1 installation to create a working portable. Run this ELEVATED from where you want your portable synergy to be located, such as "J:\SynergyPortable" Note: Elevation is required in order to successfully copy files from the Program Files directory. THIS is the folder where everything is going to be placed: E:\ If that's okay, continue. Otherwise, close this window. Press any key to continue . . . Copying Synergy binaries ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Tue Sep 18 11:49:59 2018 Source : C:\Program Files\Synergy\ Dest = E:\1 \w:1 \e \zb\ Files : *.* Options : *.* /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2018/09/18 11:49:59 ERROR 123 (0x0000007B) Creating Destination Directory E:\1 \w:1 \ The filename, directory name, or volume label syntax is incorrect. Waiting 30 seconds... Retrying... 2018/09/18 11:50:29 ERROR 123 (0x0000007B) Creating Destination Directory E:\1 \w:1 \e \ The filename, directory name, or volume label syntax is incorrect. Parsing Registry for Synergy settings Collecting Synergy Data (such as certificate and fingerprints) ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Tue Sep 18 11:50:29 2018 Source = E:\Synergy\ Dest = E:\1 \w:1 \e \zb\ Files : *.* Options : *.* /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2018/09/18 11:50:29 ERROR 2 (0x00000002) Accessing Source Directory E:\Synergy\ The system cannot find the file specified. Current Synergy command is: New Synergy command is: "synergyc.exe" "%CD%" Creating Synergy-Portable.bat All done. 1) Eject the E: drive 2) Plug it into another device 3) Run "Synergy-Portable.bat" PS: You might also want to open Synergy-Portable.bat and change the device name and/or log You can use "synergyc --help" to discover available options. Press any key to continue . . . Quote
Shawn Hall Posted September 19, 2018 Author Posted September 19, 2018 ah - I see what's going on. The %~dp0 syntax adds a trailing slash only when it's the root of the drive, which escapes the close quote and causes the following switches to be mistreated. I've uploaded a fixed version and will repair the code above in a moment. Quote
Shawn Hall Posted September 19, 2018 Author Posted September 19, 2018 Darn, not seeing a way to edit the original post. I'll have to add it as a comment instead. @ECHO OFF ::'=========================================================== :: Make-Synergy-Portable.bat :: https://12pd.com/s/Make-Synergy-Portable.txt ::'=========================================================== :: This will collect the relevant files from an existing :: Synergy v1 installation to create a working portable. :: Run this ELEVATED from where you want your portable :: synergy to be located, such as "J:\SynergyPortable" ::'=========================================================== ECHO. ECHO.::: WARNING^! ::: ECHO. ECHO.This will collect the relevant files from an existing ECHO.Synergy v1 installation to create a working portable. ECHO.Run this ELEVATED from where you want your portable ECHO.synergy to be located, such as "J:\SynergyPortable" ECHO. ECHO.Note: Elevation is required in order to successfully copy ECHO. files from the Program Files directory. ECHO. ECHO.THIS is the folder where everything is going to be placed: SET "syndest=%~dp0%" IF "%syndest:~-1%"=="\" SET "syndest=%syndest:~0,-1%" ECHO. %syndest% ECHO.If that's okay, continue. Otherwise, close this window. ECHO. PAUSE ECHO. ECHO. ECHO.Copying Synergy binaries robocopy "%ProgramFiles%\Synergy" "%syndest%" /r:1 /w:1 /e /zb ECHO.Parsing Registry for Synergy settings FOR /F "tokens=1,2*" %%a IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Synergy" /v Command') DO SET syncmd=%%c FOR /F usebackq^ tokens^=1^,2^,3^,^*^ delims^=^" %%a IN ('%syncmd%') DO ( SET "synopt=%%b" SET "syndata=%%c" SET "synserver=%%d" ) ECHO. ECHO. ECHO.Collecting Synergy Data ^(such as certificate and fingerprints^) robocopy "%syndata%\Synergy" "%syndest%\Synergy" /r:1 /w:1 /e /zb ECHO. ECHO. ECHO.Current Synergy command is: ECHO. %syncmd% ECHO. ECHO. ECHO.New Synergy command is: ECHO. "synergyc.exe" %synopt% "%%CD%%" %synserver% ECHO. ECHO. ECHO.Creating Synergy-Portable.bat ECHO."synergyc.exe" %synopt% "%%CD%%" %synserver% 1>%syndest%\Synergy-Portable.bat SET syncmd= SET synopt= SET syndata= SET synserver= ECHO. ECHO. ECHO.All done. ECHO. ECHO.1^) Eject the %syndest:~0,2% drive ECHO.2^) Plug it into another device ECHO.3^) Run "Synergy-Portable.bat" ECHO. ECHO.PS: ECHO. You might also want to open Synergy-Portable.bat and change the device name and/or logging level. ECHO. You can use "synergyc --help" to discover available options. ECHO. PAUSE Quote
Shawn Hall Posted September 19, 2018 Author Posted September 19, 2018 14 hours ago, Noam Liran said: E:\>dir Volume in drive E is Untitled Volume Serial Number is 3A2B-47CA Directory of E:\ 09/18/2018 10:28 AM 2,291 make_portable.bat 1 File(s) 2,291 bytes 0 Dir(s) 123,004,649,472 bytes free You should also be aware that running it from the root of the drive is going to put the binaries at the root of your drive. That's an extra ~18 files and 3 folders at the root, most of the files are DLLs and the executables can't be run directly without problems. On a 128GB thumb drive which is likely used for other stuff as well it could end up causing you a bit of frustration later on. Quote
Shawn Hall Posted November 14, 2018 Author Posted November 14, 2018 Found and fixed a bug in the generation script. It assumed that it would be running from a command prompt with curdir of the synergy portable location. The following fixes that and incorporates the other fixes from above. The most current version will always be available to download directly from my server, too. @ECHO OFF ::'=========================================================== :: Make-Synergy-Portable.bat :: https://12pd.com/s/Make-Synergy-Portable.txt ::'=========================================================== :: This will collect the relevant files from an existing :: Synergy v1 installation to create a working portable. :: Run this ELEVATED from where you want your portable :: synergy to be located, such as "J:\SynergyPortable" ::'=========================================================== ECHO. ECHO.::: WARNING^! ::: ECHO. ECHO.This will collect the relevant files from an existing ECHO.Synergy v1 installation to create a working portable. ECHO.Run this ELEVATED from where you want your portable ECHO.synergy to be located, such as "J:\SynergyPortable" ECHO. ECHO.Note: Elevation is required in order to successfully copy ECHO. files from the Program Files directory. ECHO. ECHO.THIS is the folder where everything is going to be placed: SET "syndest=%~dp0%" IF "%syndest:~-1%"=="\" SET "syndest=%syndest:~0,-1%" ECHO. %syndest% ECHO.If that's okay, continue. Otherwise, close this window. ECHO. PAUSE ECHO. ECHO. ECHO.Copying Synergy binaries robocopy "%ProgramFiles%\Synergy" "%syndest%" /r:1 /w:1 /e /zb ECHO.Parsing Registry for Synergy settings FOR /F "tokens=1,2*" %%a IN ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Synergy" /v Command') DO SET syncmd=%%c FOR /F usebackq^ tokens^=1^,2^,3^,^*^ delims^=^" %%a IN ('%syncmd%') DO ( SET "synopt=%%b" SET "syndata=%%c" SET "synserver=%%d" ) ECHO. ECHO. ECHO.Collecting Synergy Data ^(such as certificate and fingerprints^) robocopy "%syndata%\Synergy" "%syndest%\Synergy" /r:1 /w:1 /e /zb ECHO. ECHO. ECHO.Current Synergy command is: ECHO. %syncmd% ECHO. ECHO. ECHO.New Synergy command is: ECHO. "synergyc.exe" %synopt% "%%CD%%" %synserver% ECHO. ECHO. ECHO.Creating Synergy-Portable.bat ECHO.PUSHD "%%~dp0%%" 1>%syndest%\Synergy-Portable.bat ECHO."synergyc.exe" %synopt% "%%CD%%" %synserver% 1>>%syndest%\Synergy-Portable.bat ECHO.POPD>>%syndest%\Synergy-Portable.bat SET syncmd= SET synopt= SET syndata= SET synserver= ECHO. ECHO. ECHO.All done. ECHO. ECHO.1^) Eject the %syndest:~0,2% drive ECHO.2^) Plug it into another device ECHO.3^) Run "Synergy-Portable.bat" ECHO. ECHO.PS: ECHO. You might also want to open Synergy-Portable.bat and change the device name and/or logging level. ECHO. You can use "synergyc --help" to discover available options. ECHO. PAUSE Quote
Shawn Hall Posted February 5, 2019 Author Posted February 5, 2019 I added a separate autostart (on logon) option to work with the Synergy-Portable.bat above. Place it next to the "Synergy-Portable.bat" that the Make-Synergy-Portable.bat builds, and run it on devices that you want to be able to connect to whenever your USB is connected during startup. A stub will be created in the Windows directory that checks for whether the Synergy-Portable.bat file exists and if so, it runs it. This change means it requires elevation in order for this to work. The first file, which creates the stub and creates the scheduled task to run on logon is below. @ECHO OFF ::'=========================================================== :: Autostart.bat :: https://12pd.com/s/Synergy-Autostart.txt ::'=========================================================== :: This will create a scheduled task to run Synergy on login. :: Run this ELEVATED after generating SynergyPortable. ::'=========================================================== :: Create stub for synergy portable at this location IF EXIST "%windir%\Synergy-Portable.bat" DEL "%windir%\Synergy-Portable.bat" ECHO.IF EXIST "%~dp0\Synergy-Portable.bat" "%~dp0\Synergy-Portable.bat">"%windir%\Synergy-Portable.bat" ECHO.EXIT>>"%windir%\Synergy-Portable.bat" :: Create XML file to import scheduled task from SET XML="%~dp0\%~n0.xml" IF EXIST %XML% DEL %XML% > %XML% ECHO ^<?xml version="1.0" encoding="UTF-16"?^> >> %XML% ECHO ^<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"^> >> %XML% ECHO ^<RegistrationInfo^> >> %XML% ECHO ^<Date^>2018-10-24T07:00:00.000^</Date^> >> %XML% ECHO ^<Description^>Enables Synergy Portable to run at logon.^</Description^> >> %XML% ECHO ^<Author^>%UserDomain%\%UserName%^</Author^> >> %XML% ECHO ^</RegistrationInfo^> >> %XML% ECHO ^<Triggers^> >> %XML% ECHO ^<SessionStateChangeTrigger^> >> %XML% ECHO ^<Enabled^>true^</Enabled^> >> %XML% ECHO ^<StateChange^>SessionLock^</StateChange^> >> %XML% ECHO ^</SessionStateChangeTrigger^> >> %XML% ECHO ^<LogonTrigger^> >> %XML% ECHO ^<Enabled^>true^</Enabled^> >> %XML% ECHO ^</LogonTrigger^> >> %XML% ECHO ^</Triggers^> >> %XML% ECHO ^<Principals^> >> %XML% ECHO ^<Principal id="Author"^> >> %XML% ECHO ^<UserId^>%UserDomain%\%UserName%^</UserId^> >> %XML% ECHO ^<LogonType^>InteractiveToken^</LogonType^> >> %XML% ECHO ^<RunLevel^>HighestAvailable^</RunLevel^> >> %XML% ECHO ^</Principal^> >> %XML% ECHO ^</Principals^> >> %XML% ECHO ^<Settings^> >> %XML% ECHO ^<MultipleInstancesPolicy^>IgnoreNew^</MultipleInstancesPolicy^> >> %XML% ECHO ^<DisallowStartIfOnBatteries^>false^</DisallowStartIfOnBatteries^> >> %XML% ECHO ^<StopIfGoingOnBatteries^>false^</StopIfGoingOnBatteries^> >> %XML% ECHO ^<AllowHardTerminate^>true^</AllowHardTerminate^> >> %XML% ECHO ^<StartWhenAvailable^>false^</StartWhenAvailable^> >> %XML% ECHO ^<RunOnlyIfNetworkAvailable^>false^</RunOnlyIfNetworkAvailable^> >> %XML% ECHO ^<IdleSettings^> >> %XML% ECHO ^<StopOnIdleEnd^>false^</StopOnIdleEnd^> >> %XML% ECHO ^<RestartOnIdle^>false^</RestartOnIdle^> >> %XML% ECHO ^</IdleSettings^> >> %XML% ECHO ^<AllowStartOnDemand^>true^</AllowStartOnDemand^> >> %XML% ECHO ^<Enabled^>true^</Enabled^> >> %XML% ECHO ^<Hidden^>false^</Hidden^> >> %XML% ECHO ^<RunOnlyIfIdle^>false^</RunOnlyIfIdle^> >> %XML% ECHO ^<DisallowStartOnRemoteAppSession^>false^</DisallowStartOnRemoteAppSession^> >> %XML% ECHO ^<UseUnifiedSchedulingEngine^>false^</UseUnifiedSchedulingEngine^> >> %XML% ECHO ^<WakeToRun^>false^</WakeToRun^> >> %XML% ECHO ^<Priority^>7^</Priority^> >> %XML% ECHO ^</Settings^> >> %XML% ECHO ^<Actions Context="Author"^> >> %XML% ECHO ^<Exec^> >> %XML% ECHO ^<Command^>cmd.exe^</Command^> >> %XML% ECHO ^<Arguments^>/c start /min ^"^" ^"%windir%\Synergy-Portable.bat^"^</Arguments^> >> %XML% ECHO ^</Exec^> >> %XML% ECHO ^</Actions^> >> %XML% ECHO ^</Task^> :: Delete the task if it already exists SCHTASKS /Query /TN "SynergyPortable" >NUL 2>&1 && SCHTASKS /Delete /TN "SynergyPortable" /F >NUL 2>&1 :: Create the task by importing the XML we just created SCHTASKS /Create /TN "SynergyPortable" /XML %XML% :: Delete the temporary XML file IF EXIST %XML% DEL %XML% :: Run it SCHTASKS /Run /TN "SynergyPortable" The second file removes the stub and the scheduled task, effectively disabling autostart. @ECHO OFF ::'=========================================================== :: Autostart-Off.bat :: https://12pd.com/s/Synergy-Autostart-off.txt ::'=========================================================== :: This will remove the scheduled task for Portable Synergy. :: Run this ELEVATED. ::'=========================================================== :: Delete the stub IF EXIST "%windir%\Synergy-Portable.bat" DEL "%windir%\Synergy-Portable.bat" :: Delete the task SCHTASKS /Query /TN "SynergyPortable" >NUL 2>&1 && SCHTASKS /Delete /TN "SynergyPortable" /F >NUL 2>&1 Quote
Dom Zerchi Posted June 5, 2020 Posted June 5, 2020 (edited) Sorry, never mind. The batch file I am editing is the one that the one I am about to run now will create. Never mind. Thank you Shawn Hall, this looks fantastic. Everything is ready to go and I am about to run the batch file, elevated. But I have a question that I figure is probably important. I "might want to change the device name." Where is that? I'm sorry I don't know DOS all. Should I be editing these lines before running the batch file? Edited June 5, 2020 by Dom Zerchi I figured it out Quote
GranolaCluster Posted February 11, 2021 Posted February 11, 2021 Sorry to revive this thread. I've tried this and got it working fine but ... with SSL enabled, it does not work. The error becomes failed to verify server certificate fingerprint. Quote
jml Posted February 11, 2021 Posted February 11, 2021 I don't think that's limited to portable per se. Earlier production versions of Synergy also had problems with SSL. You might want to make sure you're on the latest code release. FWIW, I ran without SSL for a long time -- not really sure why one needs it in a local situation anyway, but you might. Quote
GranolaCluster Posted February 11, 2021 Posted February 11, 2021 (edited) 11 minutes ago, jml said: I don't think that's limited to portable per se. Earlier production versions of Synergy also had problems with SSL. You might want to make sure you're on the latest code release. FWIW, I ran without SSL for a long time -- not really sure why one needs it in a local situation anyway, but you might. I'm not running it local. I'm trying my hand at the good ol VPN block. The way Cisco VPN is configured does not allow me to split tunnel. It takes over all the network so I have no choice but to go over the internet. I've tried running a patch cable from the device and still can't get an IP. It is pretty locked down and I have no admin privs, hence I need the portable version. I tried running this portable on version 1.13 and it didn't work so I kinda got stuck on 1.10. I don't think this portability script takes into account the cert generated as a result of enabling SSL. I am able to get this working under the following conditions. - installed and running locally with or without SSL - portable and running over the internet without SSL but since my use case is going over the internet, I'm going externally so better have it encrypted. I looked at the synergy.conf and defaults to 1024bit keys, which eventually I might try changing to 2048. I'm still not sure how to get past the server cert fingerprint problem though Edited February 11, 2021 by GranolaCluster Quote
jml Posted February 11, 2021 Posted February 11, 2021 Ick. I don't have a great solution... but you say "I can't get an IP". Can you assign a static to a secondary physical interface and use that as your Synergy portal? Quote
GranolaCluster Posted February 11, 2021 Posted February 11, 2021 1 minute ago, jml said: Ick. I don't have a great solution... but you say "I can't get an IP". Can you assign a static to a secondary physical interface and use that as your Synergy portal? I wish. I can't edit the network settings due to no admin privs. But good idea, thanks for the reply. Quote
Valor Poland Posted December 5, 2022 Posted December 5, 2022 On 2/11/2021 at 3:38 PM, GranolaCluster said: I tried running this portable on version 1.13 and it didn't work so I kinda got stuck on 1.10. I don't think this portability script takes into account the cert generated as a result of enabling SSL. I know this is an old thread, but wanted to add a couple cents.. Similar situation, no admin rights. I got SSL enabled on the latest (v1.14.6) by manually adding my server fingerprint to TrustedServers.txt in the following path: C:\Users\USER_NAME\AppData\Local\Synergy\SSL\Fingerprints\TrustedServers.txt The txt file has a copy/paste of the fingerprint on one line. Then, I created a desktop shortcut with the command line options --enable-crypto --name PreSetClientName C:\Users\USER_NAME\PortableApps\SynergyPortable\synergyc.exe -1 --enable-crypto --name PreSetClientName x.x.x.x I never was able to get the BAT file that the script generated to work -- I think Synergy changes where the options are stored in the registry in v1.11. However, it did copy the needed files for me to zip and put in my "PortableApps" directory Hopefully this helps! Quote
Rabistill Posted December 21, 2023 Posted December 21, 2023 I was able to create Make-Synergy-Portable.bat, then couldn't connect to local on the client computer. Help Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.