Shawn Hall

Synergy Portable

8 posts in this topic

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.

  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. 
  2. It's a batch file so change the extension from txt to bat
  3. Put it in the folder where you want Synergy Portable to be located (such as "j:\SynergyPortable").
  4. Then run it elevated (this is important!). Elevation is required in order to successfully collect files from the Program Files directory. 
  5. 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 by Shawn Hall
added a pause at the end

Share this post


Link to post
Share on other sites

Nice Windows solution!!!!!! Great work. Wonder if something similar's possible for 2.x?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 . . .

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now