 Rank: Guest Joined: 2/18/2019(UTC) Posts: 2  Location: New Orleans
|
Edit: Decided to leave this script up, but posted a newer one in the second post. I am new to using ConnectWise Control, and had intended to deploy via GPO when I signed up. I came to realize that it isn't really supported or recommended so I went the startup script method instead. Below is what I ended up with, the only thing I took out on here was my server's IP. It's built from an old script I found on these forums, one reason I'm putting it here is just in case it helps anyone else, of course you'll have to edit to make it work for you. The main reason I'm posting though is to ask if this is still the preferred way to deploy to many machines across multiple sites on my domain? If there is some other way recommended I'd love to learn what it is. I've tested this on a few computers and it works fine, but does anyone see anything here that they think should be done differently? I'm copying the install over to the local drive in the script because I read a few times that having the install msi on the network drive can cause issues down the road. Anyway let me know if anyone has any input. Thanks. Code:
set local
set logshare="\\<my server IP>\IT Public\CWC Logs"
echo %date% %time% ---- >> %logshare%\%ComputerName%.log
echo %date% %time% the %0 script is running >> %logshare%\%ComputerName%.log
REM **
REM Check for install
REM **
set CustomConfig=None
REM Check if the screen connect client is already installed
IF EXIST "%SYSTEMDRIVE%\Program Files (x86)\ScreenConnect Client (*)" set CustomConfig=exists
IF EXIST "%SYSTEMDRIVE%\Program Files\ScreenConnect Client (*)" set CustomConfig=exists
if %CustomConfig%==exists goto Found
REM **
REM Deployment begins here
REM **
:NotFound
REM **
REM Check for installs folder
REM **
set InstallFolder=none
IF EXIST "%SYSTEMDRIVE%\Installs" set InstallFolder=exists
if %InstallFolder%==exists echo %date% %time% Install folder exists >> %logshare%\%ComputerName%.log
if %InstallFolder%==exists goto Install
md %SYSTEMDRIVE%\Installs
echo %date% %time% Install folder created on system drive >> %logshare%\%ComputerName%.log
:Install
echo %date% %time% Package not detected, Begin Deployment >> %logshare%\%ComputerName%.log
copy "\\<my server IP>\IT Public\ConnectWiseControl.ClientSetup.msi" "%SYSTEMDRIVE%\Installs\ConnectWiseControl.ClientSetup.msi" /y
start /wait msiexec /i "%SYSTEMDRIVE%\Installs\ConnectWiseControl.ClientSetup.msi" /quiet
echo %date% %time% Deployment Completed >> %logshare%\%ComputerName%.log
echo %date% %time% the %0 script has run successfully >> %logshare%\%ComputerName%.log
goto End
:Found
echo %date% %time% Screen Client install was detected, scipt terminating >> %logshare%\%ComputerName%.log
goto End
:End
Endlocal
Edited by user Wednesday, February 20, 2019 8:19:30 PM(UTC)
| Reason: Not specified
|
|
|
|
 Rank: Guest Joined: 2/18/2019(UTC) Posts: 2  Location: New Orleans
|
Since this seems like the best way to deploy for me, I went ahead and added a bit to my script. Added a custom reg key to do version checking, it will install over the old version if you deploy a new msi and update the version variable in the script. Went ahead and left the old script up in case someone doesn't want to mess with the version stuff, anyway hope this helps someone else. Code:
REM ** ScreenConnect agent install script for KDHSA written by Daniel Casbergue
REM ** CurrentVersion variable needs to be updated when you deploy a new MSI with the new version.
set local
set CurrentVersion=6.9.21870.6964
set REG_NAME="HKLM\SOFTWARE\ScreenConnect"
set KEY_NAME=Version
set logshare="\\<your IP or FDQN>\IT Public\CWC Logs"
echo %date% %time% -------- The %0 script is running >> %logshare%\%ComputerName%.log
REM ** Check to see if version registry key exists, move to not found section if not, check version if it does.
REG QUERY "HKLM\SOFTWARE\ScreenConnect" /v Version
IF %ERRORLEVEL%==0 (
echo %date% %time% Registry key exists, checking version >> %logshare%\%ComputerName%.log
Goto CheckVersion
)
IF %ERRORLEVEL%==1 (
echo %date% %time% Registry key does not exist, moving to not found>> %logshare%\%ComputerName%.log
Goto NotFound
)
REM ** Check for registry key version
:CheckVersion
FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %REG_NAME% /v %KEY_NAME% 2^>nul`) DO (
@echo %%A : %%C
set VersionNum=%%C
)
IF %VersionNum%==%CurrentVersion% (
echo %date% %time% Registry key version is up to date, checking for install >> %logshare%\%ComputerName%.log
Goto CheckInstalled
)
ELSE (
echo %date% %time% Registry key version is not up to date, moving to re-install >> %logshare%\%ComputerName%.log
Goto NotFound
)
REM ** Check if the screen connect client is already installed & Version is up to date
:CheckInstalled
set CustomConfig=none
IF EXIST "%SYSTEMDRIVE%\Program Files (x86)\ScreenConnect Client (*)" IF %VersionNum%==%CurrentVersion% set CustomConfig=uptodate
IF EXIST "%SYSTEMDRIVE%\Program Files\ScreenConnect Client (*)" IF %VersionNum%==%CurrentVersion% set CustomConfig=uptodate
if %CustomConfig%==uptodate goto Found
REM **
REM Deployment begins here
REM **
:NotFound
REM **
REM Check for installs folder
REM **
IF EXIST "%SYSTEMDRIVE%\Installs" set InstallFolder=exists
if %InstallFolder%==exists (
echo %date% %time% Install folder exists >> %logshare%\%ComputerName%.log
goto Install
)
md %SYSTEMDRIVE%\Installs
echo %date% %time% Install folder created on system drive >> %logshare%\%ComputerName%.log
:Install
echo %date% %time% Package not detected, or reg key out of date, begin Deployment >> %logshare%\%ComputerName%.log
copy "\\<your IP or FDQN>\IT Public\ConnectWiseControl.ClientSetup.msi" "%SYSTEMDRIVE%\Installs\ConnectWiseControl.ClientSetup.msi" /y
timeout 5 >nul
start /wait msiexec /i "%SYSTEMDRIVE%\Installs\ConnectWiseControl.ClientSetup.msi" /quiet
REG ADD "HKLM\SOFTWARE\ScreenConnect" /v Version /t REG_SZ /d %CurrentVersion% /f
echo %date% %time% Deployment Completed & Registry Version Key Set>> %logshare%\%ComputerName%.log
echo %date% %time% the %0 script has run successfully >> %logshare%\%ComputerName%.log
goto End
:Found
echo %date% %time% Screen Client install was detected, scipt terminating >> %logshare%\%ComputerName%.log
goto End
:End
Endlocal
Edited by user Thursday, February 21, 2019 10:23:16 PM(UTC)
| Reason: Added a quick 5 second timeout after copy, found it wouldn't install on first run sometimes.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.