When working as a system administrator, you often come across the need to install any programs remotely. Something massive can be established through group policies, something single needs to be installed using direct control of the target computer.
However, since computers with a newer version of XP than Windows began to appear in our ultraconservative office, a problem arose: the remote assistant of Windows Server 2003 (which, in general, did not suit anyone) could not connect to later OS versions. Of course, we still had the good old Remote Desktop, but sometimes you need to see exactly what the user sees on his desktop. In this case, the security policy of the office required the use of a minimum of third-party software.
After a long search, it was found that connecting to a Windows 7 session from a Windows Server 2003 session without any third-party utility will fail. The competition for the most free remote control utility was won by
UltraVNC . It is on her example that the method of remote silent installation of programs without the use of third-party utilities will be discussed below.
Formulation of the problem
For all the same minimization of the presence of the left software on the computers of the enterprise, it was decided not to push the UltraVNC installation through policies. At the same time, there was no desire for every computer where you need to connect to a user session, connect via a “remote desktop” to install UltraVNC.
')
So the task arose - to
organize the remote installation of the program X on the computer Y on demand . As a result of the work, the
install.bat file was first born, capable of performing a silent installation-configuration of the required program, and then a method was also invented to run such an installation on a remote computer without using third-party utilities (
remote-install.bat ).
Silent installation UltraVNC
The script allows you to quickly and quietly install UltraVNC when running with administrator rights on the target machine.
install.bat@echo off rem set logfile=install.log echo %date% %COMPUTERNAME%>%logfile% echo [%time:~,8%] >>%logfile% set ThePath="%1" if %ThePath% EQU "" set ThePath="%CD%" rem 64- set DISTR=UltraVNC1191(x86).exe if "%ProgramFiles(x86)%" NEQ "" set DISTR=UltraVNC1191(x64).exe rem dir "C:\Program Files\UltraVNC" >NUL if %errorlevel% EQU 0 (goto CHECK_VER) else (cls) echo [%time:~,8%] >>%logfile% goto INSTALL rem :CHECK_VER echo [%time:~,8%] >>%logfile% type "C:\Program Files\UltraVNC\Whatsnew.rtf" | find "1.1.9.1" >NUL if %errorlevel% EQU 0 (cls & goto OOPS) else (echo [%time:~,8%] >>%logfile%) rem - echo [%time:~,8%] UVNC_Service>>%logfile% net stop uvnc_service >NUL if %errorlevel% EQU 0 (echo [%time:~,8%] UVNC_Service >>%logfile%) else (echo [%time:~,8%] UVNC_Service>>%logfile%) rd /s /q "C:\Program Files\UltraVNC" >NUL if %errorlevel% EQU 0 (echo [%time:~,8%] UltraVNC >>%logfile%) else (echo [%time:~,8%] UltraVNC>>%logfile%) rem : , :INSTALL md "C:\Program Files\UltraVNC" >NUL && echo [%time:~,8%] UltraVNC>>%logfile% cls copy /y "%ThePath:"=%\ultravnc.ini" "C:\Program Files\UltraVNC" >NUL if %errorlevel% EQU 0 (echo [%time:~,8%] >>%logfile%) else (echo [%time:~,8%] >>%logfile%) rem "%ThePath:"=%\%DISTR%" /verysilent /loadinf="%ThePath:"=%\uvncinstall.inf" if %errorlevel% EQU 0 (echo [%time:~,8%] UltraVNC >>%logfile%) else (echo [%time:~,8%] UltraVNC>>%logfile%) rem - rd /q /s "C:\Documents and Settings\All Users\ \\UltraVNC" >NUL if %errorlevel% EQU 0 (echo [%time:~,8%] >>%logfile%) else (echo [%time:~,8%] >>%logfile%) cls type %logfile% echo UltraVNC goto :eof rem , , :OOPS echo [%time:~,8%] UltraVNC (1.1.9.1)>>%logfile% cls type %logfile% echo pause goto :eof
Remote start silent installation
The script allows you to remotely run install.bat with administrator (user SYSTEM) rights.
remote-install.bat @echo off rem , set /p CompName=" IP-: " if '%CompName%' EQU '' goto :eof rem - UltraVNC dir "\\%CompName%\c$\Program Files\UltraVNC" >NUL && goto CHECK_VER goto INSTALL rem :CHECK_VER type "\\%CompName%\c$\Program Files\UltraVNC\Whatsnew.rtf" | find "1.1.9.1" >NUL && goto OOPS goto INSTALL rem , C:\Temp :INSTALL md \\%CompName%\c$\Temp\UltraVNCServer xcopy /y "%CD%\*.*" \\%CompName%\c$\Temp\UltraVNCServer >NUL rem schtasks /create /s %CompName% /ru system /sc once /tn uvncinstall /tr "C:\Temp\UltraVNCServer\install.bat C:\Temp\UltraVNCServer" /ST "23:30:00" schtasks /run /s %CompName% /tn uvncinstall rem 5 () :CHECK ping 127.0.0.1 -n 5 >NUL schtasks /query /s %CompName% | find "uvncinstall" | find "" && goto :CHECK rem - schtasks /delete /s %CompName% /tn uvncinstall /f type \\%CompName%\c$\Temp\UltraVNCServer\install.log rd /q /s \\%CompName%\c$\Temp\UltraVNCServer >NUL echo . ! pause goto :eof rem - :OOPS echo UltraVNC (1.1.9.1) . pause goto :eof
Important
In order to avoid the inoperability of scripts due to misunderstandings with encodings, it is better to save both files in MS-DOS encoding (OEM 866). Also for successful installation of the program you need:
- respectively named distributions for 32 and 64-bit systems - UltraVNC1191 (x86) .exe and UltraVNC1191 (x64) .exe
- Pre-prepared file with the settings for the future UltraVNC server - ultravnc.ini (can be obtained from the already installed and configured copy of the program on any computer)
- file with installation options - uvncinstall.inf. I have it like this:
[Setup] Lang=en Dir=C:\Program Files\UltraVNC Group=UltraVNC NoIcons=0 SetupType=server_silent Components=ultravnc_server_s Tasks=installservice,startservice
Total
These bat-scripts allowed UltraVNC to be easily installed not only on Windows 7 computers, but also on problematic (from the “remote assistant” point of view) computers with Windows XP, and subsequently on Windows 8 computers. If desired, and if there is a file, With the help of these scripts you can also install other programs - if only there was a “silent” installation.
A key feature of this installation method was the use of schtasks to create, run and delete tasks after they were completed. The rest of the contents of the scripts - checks, reinsurance and all sorts of laziness to minimize manual and mental labor, if necessary, install UltraVNC on a regular computer.