#86262 - 2002-06-25 09:11 PM
VNC install script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
This script works OK, but it doesn't remember the password as supplied in the script. and therefore prompts for one when it starts... Which is it's major failing.
It wouldn't be too difficult to get this to push VNC onto other PCs, but I wanted it to work on a local client first...
dependencies: WMIService(), RegWrite(), WMI Any ideas??
code:
break on call \\server\share\udf.kix
dim $key[2] $source = "\\server\share\apps\vnc" $Destination = "%windir%\system32" $pass="3c,52,32,57,c2,a5,21,a9"
WMIService("winvnc","STOP") ;$=deltree("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\winvnc") $=deltree("HKEY_LOCAL_MACHINE\Software\ORL") $=deltree("HKEY_CURRENT_USER\Software\ORL")
copy "$source\OMNITHREAD_RT.DLL" "$destination" copy "$source\VNCHOOKS.DLL" "$destination" copy "$source\WINVNC.EXE" "$destination" copy "$source\VNCHooks_Settings.reg" "$destination"
regwrite("HKEY_LOCAL_MACHINE\Software\ORL\VNC\3.3.3","","")
$key[0]="HKEY_LOCAL_MACHINE\Software\ORL\WinVNC3\Default" $key[1]="HKEY_CURRENT_USER\Software\ORL\WinVNC3" for $loop=0 to 1 regwrite($key[$loop],"SocketConnect","1","REG_DWORD") $=WriteValue($key[$loop],"AutoPortSelect","1","REG_DWORD") $=WriteValue($key[$loop],"InputsEnabled","1","REG_DWORD") $=WriteValue($key[$loop],"LocalInputsDisabled","0","REG_DWORD") $=WriteValue($key[$loop],"IdleTimeout","0","REG_DWORD") $=WriteValue($key[$loop],"QuerySetting","2","REG_DWORD") $=WriteValue($key[$loop],"QueryTimeout","10","REG_DWORD") $=WriteValue($key[$loop],"Password","$pass","REG_BINARY") $=WriteValue($key[$loop],"PollUnderCursor","0","REG_DWORD") $=WriteValue($key[$loop],"PollForeground","1","REG_DWORD") $=WriteValue($key[$loop],"PollFullScreen","0","REG_DWORD") $=WriteValue($key[$loop],"OnlyPollConsole","1","REG_DWORD") $=WriteValue($key[$loop],"OnlyPollOnEvent","0","REG_DWORD") $=WriteValue($key[$loop],"AllowShutdown","0","REG_DWORD") $=WriteValue($key[$loop],"AllowConfig","0","REG_DWORD") next
shell 'regedit -s $destination\VNCHooks_Settings.reg' Shell "$destination\winvnc.exe -install" WMIService("winvnc","START","Automatic")
|
|
Top
|
|
|
|
#86263 - 2002-06-25 09:13 PM
Re: VNC install script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
BTW, before someone says so... Yes, I did search the site and found a couple of samples (most of which I plagarized completely, before modifying...)
|
|
Top
|
|
|
|
#86265 - 2002-06-25 10:22 PM
Re: VNC install script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#86266 - 2002-06-26 02:59 AM
Re: VNC install script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
here is one for tightVNC, but it has the same problem... It will not accept the pre configured password.
code:
break on call "\\server\share\apps\udf.kix"
$source = "\\server\share\apps\vnc" $Destination = "%windir%\system32" $pass="10,4d,d9,f7,68,2a,55,aa"
WMIService("winvnc","STOP") Shell "$destination\winvnc.exe -kill -remove" $=deltree("HKEY_LOCAL_MACHINE\Software\ORL") $=deltree("HKEY_CURRENT_USER\Software\ORL")
copy "$source\VNCHOOKS.DLL" "$destination" copy "$source\WINVNC.EXE" "$destination" copy "$source\VNCHooks_Settings.reg" "$destination"
regwrite("HKEY_LOCAL_MACHINE\Software\ORL\VNC\3.3.3","","")
$key="HKEY_LOCAL_MACHINE\Software\ORL\WinVNC3" regwrite($key,"SocketConnect","1","REG_DWORD") $=WriteValue($key,"AutoPortSelect","1","REG_DWORD") $=WriteValue($key,"InputsEnabled","1","REG_DWORD") $=WriteValue($key,"LocalInputsDisabled","0","REG_DWORD") $=WriteValue($key,"IdleTimeout","0","REG_DWORD") $=WriteValue($key,"QuerySetting","2","REG_DWORD") $=WriteValue($key,"QueryTimeout","10","REG_DWORD") $=WriteValue($key,"Password","$pass","REG_BINARY") $=WriteValue($key,"PollUnderCursor","0","REG_DWORD") $=WriteValue($key,"PollForeground","1","REG_DWORD") $=WriteValue($key,"PollFullScreen","0","REG_DWORD") $=WriteValue($key,"OnlyPollConsole","1","REG_DWORD") $=WriteValue($key,"OnlyPollOnEvent","0","REG_DWORD") $=WriteValue($key,"AllowShutdown","0","REG_DWORD") $=WriteValue($key,"AllowConfig","0","REG_DWORD")
shell 'regedit -s $destination\VNCHooks_Settings.reg' Shell "$destination\winvnc.exe -install" WMIService("winvnc","START","Automatic")
[ 26 June 2002, 03:06: Message edited by: Radimus ]
|
|
Top
|
|
|
|
#86267 - 2002-06-26 09:21 AM
Re: VNC install script
|
Ghost
Starting to like KiXtart
Registered: 2000-09-14
Posts: 171
|
On the VNC site there is a FastPush script in the contrib section, which will push VNC to the workstation and set it running, whichever version you would like to install. There is also an option to uninstall the VNC service from the machines.
The zip file also includes the many forms of VNC as well as the script.
A very nice script.
The script looks a little like this:
code:
@echo off cls :: **************************************************************************************************** :: * Richard Harris, 2000, 2001 and 2002 * :: * Remote VNC installer. See below for version number * :: * 21st Jan 2002 * :: * All rights reserved. You may distribute this script but please keep this boilerplate in. * :: * For updates on the script - check www.darkage.co.uk/vnc from time to time. Use at your own risk! * :: ****************************************************************************************************
set fpver=3.7b
:: *** CHECK THAT THE COMPUTER RUNNING THIS SCRIPT IS NT - AS IT DOESN'T WORK ON 9x *** if not "%OS%"=="Windows_NT" GOTO NOTNT
:: *** SET THE VARIABLES TO BLANK OR DEFAULT SETTINGS ***
:: tweakable variables (see the manual)
:: *** what flavour should fastpush default to (vnc, vnc9, tridia13, tridia14, etc) *** set flav=tridia152 :: *** do or do not install the viewer by default *** set viewer=yes :: *** do or do not log all installs *** set logit=no :: *** using fastpush from a specified location - you can call it from the path that way. *** :: *** do not use quote marks as this breaks IF statements. Long pathnames are okay *** :: *** leave blank for just use the current location *** set fplocation=
:: fixed variables
set test=no set use=no set logon= set pass=cheese set logvalue= set drive= set share= set force= set sharefail= set warning= set currentpath=. set newpath= set folder= set progfiles= set remove=no set configfile=no
:: *** READ THE COMMAND LINE SWITCHES *** if "%1" == "/?" goto help if "%1" == "?" goto help if "%1" == "/help" goto help if "%1" == "" goto help if "%1" == "/examples" goto examples if "%1" == "/EXAMPLES" goto examples if "%1" == "/Examples" goto examples
if "%2"=="/remove" set remove=yes if "%3"=="/remove" set remove=yes if "%4"=="/remove" set remove=yes if "%5"=="/remove" set remove=yes if "%6"=="/remove" set remove=yes if "%7"=="/remove" set remove=yes if "%8"=="/remove" set remove=yes if "%9"=="/remove" set remove=yes
if "%2"=="/uninstall" set remove=yes if "%3"=="/uninstall" set remove=yes if "%4"=="/uninstall" set remove=yes if "%5"=="/uninstall" set remove=yes if "%6"=="/uninstall" set remove=yes if "%7"=="/uninstall" set remove=yes if "%8"=="/uninstall" set remove=yes if "%9"=="/uninstall" set remove=yes
if "%2"=="/noviewer" set viewer=no if "%3"=="/noviewer" set viewer=no if "%4"=="/noviewer" set viewer=no if "%5"=="/noviewer" set viewer=no if "%6"=="/noviewer" set viewer=no if "%7"=="/noviewer" set viewer=no if "%8"=="/noviewer" set viewer=no if "%9"=="/noviewer" set viewer=no
if "%3"=="/warning" set warning=yes if "%4"=="/warning" set warning=yes if "%5"=="/warning" set warning=yes if "%6"=="/warning" set warning=yes if "%7"=="/warning" set warning=yes if "%8"=="/warning" set warning=yes if "%9"=="/warning" set warning=yes
if "%2"=="/vnc" set flav=vnc if "%2"=="/vnc9" set flav=vnc9 if "%2"=="/tridia13" set flav=tridia13 if "%2"=="/tridia14" set flav=tridia14 if "%2"=="/tridia15" set flav=tridia15 if "%2"=="/tridia152" set flav=tridia152 if "%2"=="/tightvnc" set flav=tightvnc if "%2"=="/zvnc" set flav=zvnc
if "%3"=="/vnc" set flav=vnc if "%3"=="/vnc9" set flav=vnc9 if "%3"=="/tridia13" set flav=tridia13 if "%3"=="/tridia14" set flav=tridia14 if "%3"=="/tridia15" set flav=tridia15 if "%3"=="/tridia152" set flav=tridia152 if "%3"=="/tightvnc" set flav=tightvnc if "%3"=="/zvnc" set flav=zvnc
if "%4"=="/vnc" set flav=vnc if "%4"=="/vnc9" set flav=vnc9 if "%4"=="/tridia13" set flav=tridia13 if "%4"=="/tridia14" set flav=tridia14 if "%4"=="/tridia15" set flav=tridia15 if "%4"=="/tridia152" set flav=tridia152 if "%4"=="/tightvnc" set flav=tightvnc if "%4"=="/zvnc" set flav=zvnc
if "%5"=="/vnc" set flav=vnc if "%5"=="/vnc9" set flav=vnc9 if "%5"=="/tridia13" set flav=tridia13 if "%5"=="/tridia14" set flav=tridia14 if "%5"=="/tridia15" set flav=tridia15 if "%5"=="/tridia152" set flav=tridia152 if "%5"=="/tightvnc" set flav=tightvnc if "%5"=="/zvnc" set flav=zvnc
if "%6"=="/vnc" set flav=vnc if "%6"=="/vnc9" set flav=vnc9 if "%6"=="/tridia13" set flav=tridia13 if "%6"=="/tridia14" set flav=tridia14 if "%6"=="/tridia15" set flav=tridia15 if "%6"=="/tightvnc" set flav=tightvnc if "%6"=="/tridia152" set flav=tridia152 if "%6"=="/zvnc" set flav=zvnc
if "%7"=="/vnc" set flav=vnc if "%7"=="/vnc9" set flav=vnc9 if "%7"=="/tridia13" set flav=tridia13 if "%7"=="/tridia14" set flav=tridia14 if "%7"=="/tridia15" set flav=tridia15 if "%7"=="/tridia152" set flav=tridia152 if "%7"=="/tightvnc" set flav=tightvnc if "%7"=="/zvnc" set flav=zvnc
if "%8"=="/vnc" set flav=vnc if "%8"=="/vnc9" set flav=vnc9 if "%8"=="/tridia13" set flav=tridia13 if "%8"=="/tridia14" set flav=tridia14 if "%8"=="/tridia15" set flav=tridia15 if "%8"=="/tridia152" set flav=tridia152 if "%8"=="/tightvnc" set flav=tightvnc if "%8"=="/zvnc" set flav=zvnc
if "%9"=="/vnc" set flav=vnc if "%9"=="/vnc9" set flav=vnc9 if "%9"=="/tridia13" set flav=tridia13 if "%9"=="/tridia14" set flav=tridia14 if "%9"=="/tridia15" set flav=tridia15 if "%9"=="/tridia152" set flav=tridia152 if "%9"=="/tightvnc" set flav=tightvnc if "%9"=="/zvnc" set flav=zvnc
if "%2"=="/noview" set viewer=no if "%3"=="/noview" set viewer=no if "%4"=="/noview" set viewer=no if "%5"=="/noview" set viewer=no if "%6"=="/noview" set viewer=no if "%7"=="/noview" set viewer=no if "%8"=="/noview" set viewer=no if "%9"=="/noview" set viewer=no
if "%2"=="/log" set logit=yes if "%3"=="/log" set logit=yes if "%4"=="/log" set logit=yes if "%5"=="/log" set logit=yes if "%6"=="/log" set logit=yes if "%7"=="/log" set logit=yes if "%8"=="/log" set logit=yes if "%9"=="/log" set logit=yes
if "%2"=="/user" goto user2 if "%3"=="/user" goto user3 if "%4"=="/user" goto user4 if "%5"=="/user" goto user5 if "%6"=="/user" goto user6 if "%7"=="/user" goto user7 if "%8"=="/user" goto user8
goto customini
:user2 set use=yes set logon=%3 set pass=%4 goto customini
:user3 set use=yes set logon=%4 set pass=%5 goto customini
:user4 set use=yes set logon=%5 set pass=%6 goto customini
:user5 set use=yes set logon=%6 set pass=%7 goto customini
:user6 set use=yes set logon=%7 set pass=%8 goto customini
:user7 set use=yes set logon=%8 set pass=%9 goto customini
:: *** PICK UP A CUSTOM VNC INSTALLATION HERE *** :: Looking for the new config file will be done after the path searching routine later. :customini if "%configfile%"=="no" goto header
if "%2"=="/custom" set configfile=%3 if "%3"=="/custom" set configfile=%4 if "%4"=="/custom" set configfile=%5 if "%5"=="/custom" set configfile=%6 if "%6"=="/custom" set configfile=%7 if "%7"=="/custom" set configfile=%8 if "%8"=="/custom" set configfile=%9
if "%2"=="/config" set configfile=%3 if "%3"=="/config" set configfile=%4 if "%4"=="/config" set configfile=%5 if "%5"=="/config" set configfile=%6 if "%6"=="/config" set configfile=%7 if "%7"=="/config" set configfile=%8 if "%8"=="/config" set configfile=%9
goto header
:user8 ECHO. echo Command line too long!
rem *** THE HELP SCREEN *** :help cls Echo /****************************************************************************\ echo VNC Fastpush Installer script %fpver% (c) 2002, Richard Harris echo *----------------------------------------------------------------------------* Echo * vnc (remote NT box) (blank, /vnc or /tridia) (/test) (/user user password) * echo *----------------------------------------------------------------------------* Echo * (remote NT workstation name) must not begin with \\ and if it is a pure * Echo * number address, you should use the PC's full domain name. * Echo * * Echo * /vnc or blank = VNC 3.3.3 release 7 * Echo * /vnc9 = VNC 3.3.3 release 9 (turns wallpaper off) * echo * /tridia13 /tridia14 /tridia15 = Tridia 1.3, 1.4 or 1.5 respectively * echo * /tightvnc or /zvnc = Install TightVNC 1.1/1.2 or Zebedee VNC * echo * * Echo * /noview = Do not install VncViewer to the client * Echo * /user (name) (password) = connect with these login creditials. * echo * /log = log results to current dir in results.txt * echo * /warning = Give a 10 sec warning box (tridia only) * echo * /config = use this config file from script's folder * echo * /uninstall or /remove = Deletes service, files and registry keys * echo * * echo * For examples try vnc /examples http://www.darkage.co.uk/vnc/ * Echo \****************************************************************************/ goto END
:examples cls Echo /****************************************************************************\ echo VNC Fastpush Installer script %fpver% - (c) 2002, Richard Harris echo * * echo * vnc server2 /tridia152 /noview = install tridia 1.52 to server2 but not * echo * the viewer * echo * * echo * vnc freds_pc /uninstall = remove VNC service, reg keys and files * echo * * echo * vnc freds_pc /uninstall /user engineer letmein * echo * = as above, except attach as that user * Echo * * echo * vnc smtp-mail /config serv.ini = use a custom regini file from the fastpush* echo * folder instead of machine.ini * Echo * * Echo * http://www.darkage.co.uk/vnc/ * Echo \****************************************************************************/ goto END
:: *** PRINT OUT A QUICK BOILER PLATE *** :header if "%remove%"=="yes" (echo.& echo *** Removing VNC from %1 *** & goto pathtest) echo Script is version %fpver% echo ------------------------------------------------------------ echo You want to install : %flav% if "%use%"=="no" echo Log on as : %username% if "%use%"=="yes" echo Log on as : %logon% if "%use%"=="yes" echo Use this password : %pass% if "%log%"=="yes" echo Logging results to results.txt if "%warning%"=="yes" echo Install warning box : yes if not "%configfile%"=="no" echo Use VNC reg settings from : %configfile% echo Install Vncviewer program : %viewer% echo ------------------------------------------------------------
:: *** CHECK WHAT DIRECTORY THE SCRIPT IS IN AND ADJUST THE PATH *** :: *** CHECK TO SEE IF THE PATH HAS BEEN ADDED PREVIOUSLY *** :: *** ADD UTILS TO FRONT OF PATH. THIS MAKES SURE CORRECT PROGS ARE CALLED *** :pathtest set oldpath=%path% :: Find the current directory for /f "tokens=3,*" %%i in ('dir .^|find /i "directory"') do @set currentpath=%%i
:: If you have a set location for fastpush and you've specified it in the start up variables if "%fplocation%"=="" goto pathappend if not exist "%fplocation%\vnc.cmd" goto novnccmd set currentpath=%fplocation% echo Script will use the specified path of : "%currentpath%" goto cfgcheck
:pathappend if not exist vnc.cmd (echo ERROR: You must run fastpush from it's host folder not the path&goto end) for /f "tokens=1,* delims=;" %%i in ('path^|find /i "%currentpath%"') do @set newpath=%%i if "%newpath%"=="" path=%currentpath%\utils;%path%
:cfgcheck if "%configfile%"=="no" goto unc
:: *** if there's no configfile set, then skip on to the unc routine *** echo. if "%configfile%"=="no" goto unc if not exist "%currentpath%\%configfile%" goto customerror Echo "%currentpath%\%configfile%" will be used by regini to install custom VNC settings. goto unc
:customerror echo. echo ******************************************************************** Echo * ERROR! The custom settings file cannot be found. Please place * echo * it in the same folder as fastpush and do not specify a full path * echo ******************************************************************** goto end
:unc :: *** CHECK TO SEE THAT THE TARGET NAME ISN'T AN UNC *** set wsname= for /f "tokens=1,*" %%i in ('echo %1^|find /i "\\"') do @set wsname=%%i if "%wsname%"=="%1" goto help if "%wsname%"=="" echo Machine name "%1" is valid.
:: *** PING THE TARGET MACHINE TO SEE IF IS ACTIVE *** :: *** Checks for TTL as this is international *** Echo. Echo Please wait while the TCP/IP connection on %1 is tested. set targetstatus= for /f "skip=3 tokens=6" %%g in ('ping %1^|find /i "TTL"') do @set targetstatus=%%g if "%targetstatus%"=="" (echo Machine "%1" is not pingable via IP&goto noip) if not "%targetstatus%"=="" (echo Machine "%1" is alive, script continuing&goto connecting) goto end
: *** LOG ON TO THE REMOTE PC *** :connecting if "%use%"=="yes" goto customlogon net use \\%1\ipc$ goto ipcstatus
:customlogon net use \\%1\ipc$ /user:%logon% %pass%
:: *** CHECK TO SEE IF THE IPC NULL SESSION WAS ESTABLISHED *** :IPCSTATUS set ipc= for /f "tokens=1,*" %%i in ('net use^|find /i "\\%1\ipc$"') do @set ipc=%%i if "%ipc%"=="OK" goto sharecheck if "%ipc%"=="" goto drivefail goto end
:: *** READ REMOTE PC'S SHARES AND WORK OUT WHICH DRIVE NT LIVES ON *** :SHARECHECK echo Checking share access on %1 FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRoot" \\%1') DO SET share=%%B for /f "tokens=1* delims=:\" %%i in ('echo %share%^|find /i ":"') do @set remotetarget=%%i FOR /F "tokens=1* delims=:\" %%C IN ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRoot" \\%1') DO SET folder=%%D FOR /F "tokens=2 delims=:\" %%G IN ('REG QUERY "HKLM\software\Microsoft\Windows\CurrentVersion\ProgramFilesDir" \\%1') DO SET progfiles=%%G set progfiles=%progfiles%\Orl\VNC :: don't use quotes on the progfiles variable, it gets upset! :-) echo Windows (on machine %1) is on drive %remotetarget% in %folder% and VNC will be echo installed into %remotetarget%:\%progfiles% on %1. echo. if "%remotetarget%"=="" goto regfail goto netuse
:regfail REM *** NO ADMIN SHARE WAS FOUND, SO EXIT GRACEFULLY *** Echo ************************************************************************** Echo * Script could not find where NT is installed on the remote machine. * Echo ************************************************************************** goto cleanup
:: *** MAKE A LINK TO THE REMOTE PC AND RECREATE DRIVE SHARE IF NECESSARY *** :netuse if exist \\%1\%remotetarget%$\*.* goto installcheck echo The %remotetarget%$ share was unavailable. Attempting to recrate it. rmtshare \\%1\%remotetarget%$=%remotetarget%:\
if exist \\%1\%remotetarget%$\*.* goto installcheck goto drivefail
:installcheck :: *** CHECK FOR EXISTING VNC INSTALL AND IF NECESSARY, KILL THE SERVICE ***
set vncstate= echo. for /f "tokens=4 delims= " %%i in ('sc \\%1 query winvnc^|find /i "state"') do @set vncstate=%%i if "%vncstate%"=="RUNNING" (echo Vnc is running on %1.&goto stopservice) if "%vncstate%"=="" (echo The VNC service is not active on %1. Continuing with script.&goto :choosevnc) if "%vncstate%"=="STOPPED" goto deleteservice goto end
:stopservice Echo Stopping the WinVNC service on %1. sc \\%1 STOP winvnc > nul timeout 8
:deleteservice Echo Deleting the WinVNC service on %1. sc \\%1 DELETE winvnc Echo Deleting previous VNC registry keys from %1. reg delete HKLM\software\orl\winvnc3 \\%1 /force reg delete HKU\.Default\Software\Orl \\%1 /force
:: *** CHOOSE THE VNC FLAVOUR AND INSTALL AS NECESSARY *** :choosevnc set targetpath="\\%1\%remotetarget%$\%progfiles%" if "%remove%"=="yes" goto removevnc echo. echo Your command line option was to install %flav%. echo. echo Destination for installation will be %targetpath%.
:: *** Use the flavour variable to pick the right source folder for VNC *** if not exist %targetpath% md %targetpath% if exist %targetpath% Echo Directory %targetpath% exists. echo Copy files to %targetpath%. xcopy "%currentpath%\%flav%\v*.dll" %targetpath% /f /r /v xcopy "%currentpath%\%flav%\w*.*" %targetpath% /f /r /v xcopy "%currentpath%\%flav%\omni*.dll" "\\%1\%remotetarget%$\%folder%\system32" /f /r /v if exist "%currentpath%\%flav%\z*.dll" xcopy "%currentpath%\%flav%\z*.dll" %targetpath% /f /r /v if "%viewer%"=="yes" xcopy "%currentpath%\%flav%\vncvi*.exe" %targetpath% /f /r /v
:: *** CHECK FOR CUSTOM INSTALL, IF SO DO IT AND SKIP ON *** if "%configfile%"=="no" goto defaultvnc Echo . echo ******************************************************************************* Echo * Warning! You are about to use your own registry ini file to control VNC * Echo * Unless all settings are correct, the service may not start AND * echo * you may damage the registry of the remote computer * echo * * Echo * Only use ini files that have been created by exporting the keys with regdir * Echo * eg: regdir \registry\machine\software\orl\winvnc3\default > c:\test.ini * echo * * Echo * Rerun this script with /remove will delete VNC and the existing standard * echo * keys as regini will not replace existing registry entries * echo ******************************************************************************* pause echo. Echo Cross your fingers! :-) echo regini "%currentpath%\%configfile%" -m \\%1 regini -m \\%1 "%currentpath%\%configfile%"
timeout 10 goto installhelper
:: *** INSTALL THE DEFAULT VNC SETTINGS *** :defaultvnc Echo Installing the default settings for VNC into the remote registry. Please wait. Echo regini -m \\%1 "%currentpath%\common\machine.ini" regini -m \\%1 "%currentpath%\common\machine.ini" > nul
:: *** Check what flavour of VNC and install any REG tweaks if required *** if "%flav%"=="vnc9" regini -m \\%1 "%currentpath%\common\vnc9nopaper.ini" if "%warning%"=="yes" regini -m \\%1 "%currentpath%\common\warning.ini"
:: *** ALLOW FOR CUSTOM REGISTRY SETTINGS *** :: *** If a file that matches the machine name exists, copy this into the registry. *** :: *** This allows different passwords, IP restriction, etc. Suggested by Ryan Casey *** if exist "%currentpath%\common\%1.ini" regini -m \\%1 "%currentpath%\common\%1.ini" > nul
:installhelper :: *** THE INST ROUTINE INSTALLS THE VNC SERVICE AND HELPER *** Echo Installing WinVNC to %remotetarget%:\%progfiles% SC \\%1 create WinVNC binpath= "%remotetarget%:\%progfiles%\WinVNC.exe -service" type= own type= interact start= auto
:: *** INSTALL THE SERVICE HELPER TO THE REMOTE REGISTRY *** if exist "%currentpath%\path.tmp" del "%currentpath%\path.tmp" if exist "%currentpath%\helper.ini" del "%currentpath%\helper.ini"
Echo Setting VNC Helper in HKLM\Software\microsoft\windows\currentversion\run to: echo WinVNC = "%remotetarget%:\%progfiles%\winvnc.exe" -servicehelper echo WinVNC = "%remotetarget%:\%progfiles%\winvnc.exe" -servicehelper > path.tmp
copy "%currentpath%\common\helper.ini" + "%currentpath%\path.tmp" "%currentpath%\helper.tmp" > nul regini -m \\%1 "%currentpath%\helper.tmp"
del "%currentpath%\*.tmp"
sc \\%1 start winvnc goto sucess
:FORCECHECK if not "%force%"=="yes" goto drivefail rmtshare \\%1\%remotedrive%$=%remotedrive%:\ if "%sharefail%"="yes" goto DRIVEFAIL set sharefail=yes goto netuse
:: *** REMOVE THE VNC PROGRAM AND REGISTRY SETTINGS *** :removevnc echo. echo Your command line option was to remove VNC from %1. echo. echo VNC will be deleted from %targetpath% echo and the registry entries will also be deleted. echo This script will not remove any shortcuts though. echo. timeout 30 echo Files and host directory will be deleted from %targetpath% echo. if exist %targetpath% (rd %targetpath% /q /s & Echo %targetpath% folder removed.) if exist "\\%1\%remotetarget%$\%folder%\system32\omnithread_rt.dll" del "\\%1\%remotetarget%$\%folder%\system32\omnithread_rt.dll" /s Echo Removing \\%1\ipc$ link. net use \\%1\ipc$ /del set logvalue=killed if "%logit%"=="yes" goto logging goto END
:NOIP echo. echo ************************************************************************* echo * Error: IP access to machine is not available! Check network and power * echo ************************************************************************* set logvalue=noip if "%logit%"=="yes" goto logging goto END
:EMPTY echo. echo ***************************************************** Echo * Error! Echo You have not specified a machine name * echo ***************************************************** if "%logit%"=="yes" goto logging goto END
:NOTNT echo. echo ************************************************ Echo * Error: Echo This program only works under NT * echo ************************************************ if "%logit%"=="yes" goto logging goto END
:NOVNCCMD echo. echo ******************************************************************************** Echo * Error: vnc.cmd file not found with the path specified in fplocation variable * echo ******************************************************************************** set logvalue=novndcmd if "%logit%"=="yes" goto logging goto END
:DRIVEFAIL echo. echo ***************************************************************************** Echo * Error: Echo There was no drive mapped to the target machine's systemdrive * Echo * Try a manual net use %netdrv% \\machine\drive$ /user:admin_account * Echo * NB: Make sure the target PC is not a Windows 9x or Linux box * echo ***************************************************************************** set logvalue=drivefail if "%logit%"=="yes" goto logging goto END
:SUCESS set logvalue=installed goto cleanup
:: *** DELETE THE DRIVE MAPPING AND KILL THE IPC CONNECTION OFF TOO *** :cleanup net use \\%1\ipc$ /del if exist %netdrv%: net use %netdrv%: /del echo ------------------------------------------------------------ echo You want to install : %flav% if "%use%"=="yes" echo Log on as : %logon% if "%use%"=="yes" echo Use this password : hidden if "%log%"=="yes" echo Logging results to results.txt if "%warning%"=="yes" echo Install warning box : yes if not "%configfile%"=="no" echo Use VNC reg settings from : %configfile% echo Install Vncviewer program : %viewer% echo ------------------------------------------------------------ if "%logit%"=="yes" goto logging goto END
:logging echo. echo Logging results to "%currentpath%\results.txt" :: *** PIPE THE TIME AND DATE INTO VARIABLES *** for /f "tokens=2,*" %%i in ('date/t') do @set zdate=%%i for /f "tokens=1,*" %%j in ('time/t') do @set zclock=%%j
:: *** IF RESULTS FILES DOESN'T EXIST, THEN MAKE ONE *** if not exist results.txt echo Fastpush Installation Log (date / time / target / results) > results.txt
:: *** TIME DATE blah blah PIPED OUT TO TMP FILE *** if "%logvalue%"=="installed" echo %zdate% : %zclock% : %1 : %flav% was installed to %1. > "%currentpath%\results.tmp" if "%logvalue%"=="noip" echo %zdate% : %zclock% : %1 : Error: %1 not pingable. Check TCP/IP. > "%currentpath%\results.tmp" if "%logvalue%"=="noreg" echo %zdate% : %zclock% : %1 : NT system folder not found. > "%currentpath%\results.tmp" if "%logvalue%"=="noshare" echo %zdate% : %zclock% : %1 : $Admin share on %1 unavailable. Check shares. > "%currentpath%\results.tmp" if "%logvalue%"=="drivefail" echo %zdate% : %zclock% : %1 : Failed to logon to %1. Check logon/shares. > "%currentpath%\results.tmp" if "%logvalue%"=="killed" echo %zdate% : %zclock% : %1 : VNC service and files were removed. > "%currentpath%\results.tmp" if "%logvalue%"=="novnccmd" echo %zdate% : %zclock% : %1 : VNC command file not found. Check path variable > "%currentpath%\results.tmp"
ren "%currentpath%\results.txt" oldresults.tmp > nul copy "%currentpath%\oldresults.tmp" + "%currentpath%\results.tmp" "%currentpath%\results.txt" > nul del "%currentpath%\*.tmp" > nul
:END set user= set pass= Echo Restoring old path. set path=%oldpath%
_________________________
Who are you? Who slips into my robot body and whispers to my ghost?
|
|
Top
|
|
|
|
#86268 - 2002-06-26 09:42 AM
Re: VNC install script
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
This is the script that I used to use. You can tell it's been around a long time, no UDFs or fancy stuff like that
Anyhow, it used to work and install the password ok, so you should be able to pick the bones out of it.
The only thing you will need to change is the password, obviously.
The script expects the following files to be in a subdirectory "files" where the script is running: quote: msvcrt.dll msvcirt.dll omnithread_rt.dll vnchooks.dll winvnc.exe
code:
; VNC Distribution Kix Script
; This script will copy the VNC listener software, run the service install and ; install a basic set of registry keys.
; Set the "AllowConfig" and "AllowShutdown" entries to "1" if you want them to ; be available to users. By default this script sets them so that users cannot ; stop the VNC service, and cannot change the parameters.
; You will need to do an install and set the password to get the hex values for ; the "Password" entry.
; This install expects the distro to be available in "Files" under the current ; directory.
; Set the program file path here: "Creating directory structure..." ? $INSTALLPATH="C:\Program Files" $DirName="$INSTALLPATH\ORL" GoSub "MakeDir" $DirName="$INSTALLPATH\ORL\VNC" GoSub "MakeDir"
"Copying runtime files..." ? copy "files\*.*" $DirName
; Run the service install "Installing VNC service..." ? Shell "$DirName\winvnc.exe -install" if @ERROR "FATAL: Service install failed with error code @ERROR" EXIT endif
"Creating base registry information..." ? $Key="HKEY_LOCAL_MACHINE\Software\ORL" GoSub "MyAddKey"
$Key="HKEY_LOCAL_MACHINE\Software\ORL\VNC" GoSub "MyAddKey"
$Key="HKEY_LOCAL_MACHINE\Software\ORL\VNC\3.3.3" GoSub "MyAddKey"
$Key="HKEY_LOCAL_MACHINE\Software\ORL\WinVNC3" GoSub "MyAddKey"
$Key="HKEY_LOCAL_MACHINE\Software\ORL\WinVNC3\Default" GoSub "MyAddKey" $Entry="SocketConnect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="AutoPortSelect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="InputsEnabled" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="LocalInputsDisabled" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="IdleTimeout" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="QuerySetting" $Value="2" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="QueryTimeout" $Value="10" $Type="REG_DWORD" GoSub "MyWriteValue" ; Do a sample install and set the password to get the hex values for the next string. $Entry="Password" $Value="c137b04f51ccab36" $Type="REG_BINARY" GoSub "MyWriteValue" $Entry="PollUnderCursor" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="PollForeground" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="PollFullScreen" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="OnlyPollConsole" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="OnlyPollOnEvent" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" ; Set to "1" to allow users to stop the service $Entry="AllowShutdown" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" ; Set to "1" to allow users to change the config $Entry="AllowConfig" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL" GoSub "MyAddKey"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks" GoSub "MyAddKey"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs" GoSub "MyAddKey"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\WINVNC.EXE" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_MButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_RButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\CALC.EXE" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\CLOCK.EXE" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\explorer.exe" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\fpxpress.exe" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\Ide.exe" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\iexplore.exe" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\MSDEV.EXE" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\mspaint.exe" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCHooks\Application_Prefs\NOTEPAD.EXE" GoSub "MyAddKey" $Entry="use_GetUpdateRect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Timer" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_KeyPress" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_Deferral" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="use_LButtonUp" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\WinVNC3" GoSub "MyAddKey" $Entry="SocketConnect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="AutoPortSelect" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="InputsEnabled" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="LocalInputsDisabled" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="IdleTimeout" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="QuerySetting" $Value="2" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="QueryTimeout" $Value="10" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="Password" $Value="c137b04f51ccab36" $Type="REG_BINARY" GoSub "MyWriteValue" $Entry="PollUnderCursor" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="PollForeground" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="PollFullScreen" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="OnlyPollConsole" $Value="1" $Type="REG_DWORD" GoSub "MyWriteValue" $Entry="OnlyPollOnEvent" $Value="0" $Type="REG_DWORD" GoSub "MyWriteValue"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCviewer" GoSub "MyAddKey"
$Key="HKEY_CURRENT_USER\Software\ORL\VNCviewer\MRU" GoSub "MyAddKey" $Entry="index" $Value="A" $Type="REG_SZ" GoSub "MyWriteValue" $Entry="A" $Value="10.16.28.24:0" $Type="REG_SZ" GoSub "MyWriteValue"
:MyAddKey if ExistKey($Key) if AddKey($Key) "ABORTING: Error @ERROR adding key $Key" ? " Additional Info: @SERROR" ? exit endif endif RETURN
:MyWriteValue if WriteValue($Key,$Entry,$Value,$Type) "WARNING: Error @ERROR updating $Entry in $Key with value $Value" ? " Additional Info: @SERROR" ? endif RETURN
:MakeDir md $DirName if @ERROR "FATAL: Could not create $DirName - maybe it already exists?" EXIT endif RETURN
|
|
Top
|
|
|
|
#86269 - 2002-06-26 10:07 AM
Re: VNC install script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
ok... this has it working. Thanks Richard (it was your script that I disected to begin with, and just realized the commas in the password had to be removed.. damn binary values)
this is using TightVNC stored on a fileserver, only requires 3 files VNCHOOKS.DLL, WINVNC.EXE, VNCHooks_Settings.reg copied directly from the distribution zip
I'll see about configuring it to push to client machines... perhaps as an admin script to push it, connect to it, upon disconnect remove it.
code:
break on call "\\server\share\udf.kix"
$source = "\\server\share\apps\vnc" $Destination = "%windir%\system32" $key = "HKEY_LOCAL_MACHINE\Software\ORL\WinVNC3\default" $password = "154cb9f7422a55aa"
; ************** Delete prior VNC if exists ****************** WMIService("winvnc","STOP") Shell "$destination\winvnc.exe -kill -remove" $=deltree("HKEY_LOCAL_MACHINE\Software\ORL") $=deltree("HKEY_CURRENT_USER\Software\ORL") del "$destination\VNCHOOKS.DLL" del "$destination\WINVNC.EXE" del "$destination\VNCHooks_Settings.reg"
; ********************* Install VNC ************************** copy "$source\VNCHOOKS.DLL" "$destination" copy "$source\WINVNC.EXE" "$destination" copy "$source\VNCHooks_Settings.reg" "$destination"
regwrite($key,"SocketConnect","1","REG_DWORD") $=WriteValue($key,"AutoPortSelect","1","REG_DWORD") $=WriteValue($key,"InputsEnabled","1","REG_DWORD") $=WriteValue($key,"LocalInputsDisabled","0","REG_DWORD") $=WriteValue($key,"IdleTimeout","0","REG_DWORD") $=WriteValue($key,"QuerySetting","2","REG_DWORD") $=WriteValue($key,"QueryTimeout","10","REG_DWORD") $=WriteValue($key,"Password","$password","REG_BINARY") $=WriteValue($key,"PollUnderCursor","0","REG_DWORD") $=WriteValue($key,"PollForeground","1","REG_DWORD") $=WriteValue($key,"PollFullScreen","0","REG_DWORD") $=WriteValue($key,"OnlyPollConsole","1","REG_DWORD") $=WriteValue($key,"OnlyPollOnEvent","0","REG_DWORD") $=WriteValue($key,"AllowShutdown","0","REG_DWORD") $=WriteValue($key,"AllowConfig","0","REG_DWORD")
shell 'regedit -s $destination\VNCHooks_Settings.reg' Shell "$destination\winvnc.exe -install" WMIService("winvnc","START","Automatic")
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2082 anonymous users online.
|
|
|