> I would like to install TightVNC using Unattended, so that
> after it is
> installed, I can log on to the machine remotely using password I
> specified (with Unattended).
I hacked the the scripts from http://www.darkage.co.uk/vnc/ to install
ultravnc on the local box - as it uses domain auth to validate users ;)
The attatched file (rename to vnc7.cmd) is the one I use - I call it like
this:
todo.pl "%Z%\packages\VNC\vnc7.cmd %COMPUTERNAME%"
It relies on some of the unattended environment variables being setup, but
I've also used that script in a round about way to install on users dialed
in over a 33 modem link in a couple of minutes - and found the quality of
the connection over the link to be very very good.
HTH,
Mark.
--
This e-mail message may contain confidential or privileged information.
Recipients are requested to preserve this confidentiality and to advise
the sender immediately of any error in transmission.
Any views/opinions expressed in this email are that of the author and
may not reflect the views of Salamis Group - www.salamisgroup.com
@echo off
%Z%
cd %Z%\packages\VNC
cls
::
****************************************************************************************************
:: * Richard Harris (c), 1999 - 2003
*
:: * Remote VNC installer. See below for version number
*
:: * 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=7.0
set oldpath=%path%
:: *** 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=ultra
:: *** do or do not install the viewer by default ***
set viewer=no
:: *** do or do not log all installs ***
set logit=yes
:: *** 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=
:: *** If you always want start menu VNC shortcuts installing, say
yes. If not, put no ***
:: *** You will need Windows Scripting Host to make use of this
VBS creation routine ***
set shortcut=no
:: *** Copy a script to the user's machine that reports computer
name, IP, etc ***
:: *** Turning shortcut=yes off will stop a link being made to the
user's desktop ***
set macrep=yes
:: *** Should the VNC service start automatically or be manual?
***
:: *** yes = automatic and no = manual
***
set service=yes
:: *** Set cmdcheck to yes to check for the reskit tool, set to no
if no check wanted ***
:: *** Scan variable includes the file names of each util to check
for ***
:: *** You also have to set cmdarray equal to the number of
ojbects you want to check on ***
set cmdcheck=yes
set cmdarray=8
set scan=XCMD REG REGDIR REGINI RMTSHARE SC SHORTCUT TIMEOUT
:: fixed variables
set test=no
set use=no
set logon=
set pass=
set logvalue=
set drive=
set share=
set force=
set sharefail=
set warning=no
set currentpath=.
set newpath=
set folder=
set progfiles=
set remove=no
set configfile=no
set remotetarget=
set reg=no
set startpath=
set remotedesk=
set commondesk=
set targetpc=
set lnkfolder=
set missing=no
set passflag=no
set psexec=no
set ping=yes
set oprogfiles=
:: *** READ THE COMMAND LINE SWITCHES ***
if "%1" == "" goto help
:: *** FIND THE COMMAND OPTIONS ***
if "%1" == "" goto help
if "%1" == "/?" goto help
set test=/?
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" goto help
set test=/flavour
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" goto flavourhelp
set test=/examples
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" goto examples
set test=/reg
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set reg=yes
set test=/remove
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set remove=yes
set test=/uninstall
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set remove=yes
set test=/noview
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set viewer=no
set test=/warning
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set warning=yes
set test=/log
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set logit=yes
set test=/noshortcut
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set shortcut=no
set test=/manual
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set service=no
set test=/pwd
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set passflag=yes
set test=/psexec
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set psexec=yes
set test=/noping
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" set ping=no
:: *** FIND WHAT VERSION OF VNC PPL WANT TO INSTALL ***
set test=/realb4
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/ultra
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/real337
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/real336
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/real334
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/vnc9
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/vnc
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/mvnc
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/zvnc
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/esvnc112
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/esvnc111
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/esvnc11
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/esvnc
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%111& goto fchoice
set test=/tight123
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tight124
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tight125
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tight126
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tight128
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tightvnc
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%126&goto fchoice
set test=/tridia13
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tridia14
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tridia152
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tridia15
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%&goto fchoice
set test=/tridia
for /f "tokens=* delims= " %%p in ('echo %1%2%3%4%5%6%7%8%9^|find /i /c
"%test%"') do @set pv=%%p
if "%pv%"=="1" echo VNC command switch of %test% will be used. & set
flav=%test%152& goto fchoice
:fchoice
if "%flav%"=="" Echo No valid command line was chosen.& set logvalue=nocmd&
goto end
if not "%remove%"=="yes" Echo The final choice will be %flav%.
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 * /user (name) (password) = connect with these login creditials.
*
echo * /pwd = encrypt given password into VNC
settings *
echo * /reg = No file install, just update the
registry *
echo *
*
echo * /uninstall or /remove = Deletes service, files and registry
keys *
echo *
*
Echo * /noview = Do not install VncViewer to the client
*
echo * /log = log results to current dir in
results.txt *
echo * /config = use this config file from script's
folder *
echo * /noshortcut = Do not create Start Menu links on
target *
echo * /manual = Set service to not start automatically
*
echo *
*
echo * To list supported WinVNC variations use /flavour
*
echo * For examples try vnc /examples
http://www.darkage.co.uk/ *
Echo
\****************************************************************************/
goto END
:flavourhelp
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 * /realb4 = RealVNC 4 Beta 4
*
Echo * /vnc = VNC 3.3.3 release 7
*
Echo * /vnc9 = VNC 3.3.3 release 9 (turns wallpaper
off) *
echo * /real334 = RealVNC (release 3.3.4)
*
echo * /real336 = RealVNC (release 3.3.6)
*
echo * /mvnc = RealVNC (code enhanced)
*
echo * /real337 = RealVNC (release 3.3.6)
*
echo * /tight12x (x is 8 to 9) = Install TightVNC version 1.28 or 1.129
*
echo * /tridia13 /tridia14 /tridia15 = Install Tridia 1.3, 1.4, 1.5 or 1.52
*
echo * /tridia152
*
echo *
*
echo * /zvnc = Install zVNC (zebedee comp/encryption)
*
echo * /ultra = Install UltraVNC (NTLM and file
transfer *
echo * /esvnc11 /esvnc111 /esvnc112 = Install esVNC (file transfer etc)
*
echo *
*
echo * You can set the default VNC choice using the "flav" variable (see
script) *
echo * For examples try vnc /examples
http://www.darkage.co.uk/ *
Echo
\****************************************************************************/
goto end
:examples
cls
Echo
/****************************************************************************\
echo VNC Fastpush Installer script %fpver% - (c) 2002, Richard Harris
echo * vnc server2 /tridia152 /noview = install tridia 1.52 but not the viewer
*
echo *
*
echo * vnc joe /reg /config d:\ps.ini = Do not install any files but delete
and *
echo * update VNC settings with the new ini
file *
echo *
*
echo * vnc joe /reg = Do not install any files. Overwrite
*
echo * existing settings with common settings
*
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 * vnc smtp2 /config d:\serv.ini = use a custom file from the specified
path *
Echo *
*
Echo * vnc user4 /warning = install warning box
*
Echo *
http://www.darkage.co.uk/ *
Echo
\****************************************************************************/
goto END
:: *** PRINT OUT A QUICK BOILER PLATE ***
:header
set targetpc=%1
if "%remove%"=="yes" (echo.& echo *** Removing VNC from %targetpc% *** & goto
pathtest)
echo.
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%
echo Log output to results.txt : %logit%
echo Install warning box : %warning%
if not "%configfile%"=="no" echo Use VNC reg settings from : %configfile%
if "%reg%"=="yes" echo Install method : Leave files, overwrite
registry
if "%reg%"=="no" echo Install method : Overwrite files and
registry
echo Install Vncviewer program : %viewer%
echo 'My Details' desktop icon : %macrep%
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%
FOR /F "tokens=*" %%i IN ('CD') DO SET currentpath=%%i
:pathcheck
:: *** ADD UTILS TO PATH REGARDLESS OF OPTIONS ***
set test=\\
for /f "tokens=* delims= " %%p in ('echo %fplocation%^|find /i /c "%test%"') do
@set pushd=%%p
if "%pushd%"=="1" (
echo FPLOCATION set to UNC path
Echo will use PUSHD to link to directory
PUSHD %fplocation%
FOR /F "tokens=*" %%i IN ('CD') DO SET currentpath=%%i
)
if "%fplocation%"=="" if exist "%currentpath%\vnc7.cmd" (
Echo.
echo R1
echo VNC found and updating path
set fplocation=%currentpath%
path="%currentpath%\utils";%path%
goto cfgcheck
)
if NOT "%fplocation%"=="" if exist "%fplocation%\vnc7.cmd" (
Echo Result - R2
echo.
echo VNC found in %fplocation%
set currentpath=%fplocation%
goto cfgcheck
)
if "%fplocation%"=="" if NOT exist "%currentpath%\vnc7.cmd" (
echo.
Echo Error code - R3
echo VNC is not in the current folder and no FPLOCATION was set.
echo Either CD into a folder containing VNC or set FPLOCATION.
goto end
)
pause
goto end
:cfgcheck
Echo Path statement has been backed up and will be restored at the end of the
script
if "%configfile%"=="no" goto cmdcheck
:: *** if there's no configfile set, then skip on to the unc
routine ***
echo.
if "%configfile%"=="no" goto unc
if exist "%configfile%" Echo Config file found and will be used by regini to
install custom settings. & goto unc
if not exist "%currentpath%\%configfile%" goto customerror
Echo "%currentpath%\%configfile%" will be used by regini to install custom VNC
settings.
goto cmdcheck
: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
:: *** UTILITY EXIST CHECK ROUTINE ***
:cmdcheck
:: Scan variable includes the file names of each util to check for
if "%cmdcheck%"=="no" goto unc
Echo Checking Utility availability... please wait.
:: *** Calling the CHKCOUNT routine at the end of the script ***
FOR /L %%G IN (1,1,%cmdarray%) DO @call :chkcount %%G
if "%missing%"=="yes" goto UTILFAIL
echo.
:unc
:: *** CHECK TO SEE THAT THE TARGET NAME ISN'T AN UNC ***
set wsname=
for /f "tokens=1,*" %%i in ('echo %targetpc%^|find /i "\\"') do @set wsname=%%i
if "%wsname%"=="%targetpc%" echo. & echo Workstation name contains backslashes.
Attempting removal. & set targetpc=%wsname:~2,30%
echo Target pc will be '%targetpc%'.
if "%wsname%"=="%targetpc%" goto help
if "%wsname%"=="" echo Machine name "%targetpc%" is valid.
:: *** PING THE TARGET MACHINE TO SEE IF IS ACTIVE ***
:: *** Checks for TTL as this is international ***
if "%ping%"=="no" (
echo.
echo Skipping PING as requested
goto vncpasswd
)
Echo.
Echo Please wait while the TCP/IP connection on %targetpc% is tested.
set targetstatus=
for /f "skip=3 tokens=6" %%g in ('ping %targetpc%^|find /i "TTL"') do @set
targetstatus=%%g
if "%targetstatus%"=="" echo Machine "%targetpc%" is not pingable via IP & goto
noip
if not "%targetstatus%"=="" echo Machine "%targetpc%" is alive, script
continuing & goto vncpasswd
echo fail on ping test?
goto end
:vncpasswd
if NOT "%passflag%"=="yes" goto :connecting
Echo.
Echo Fastpush will encrypt and use the password you supplied.
Echo WARNING! This will override any password set in machine.ini or elsewhere
if "%2"=="/pwd" set vncpass=%3
if "%3"=="/pwd" set vncpass=%4
if "%4"=="/pwd" set vncpass=%5
if "%5"=="/pwd" set vncpass=%6
if "%6"=="/pwd" set vncpass=%7
if "%7"=="/pwd" set vncpass=%8
if "%8"=="/pwd" set vncpass=%9
set passtest=A%vncpass%A
if "%passtest%"=="AA" goto PWDFAIL
if exist "%fplocation%\%targetpc%pass.ini" del "%fplocation%\%targetpc%pass.ini"
"%fplocation%\utils\vncenc" %vncpass% > "%fplocation%\%targetpc%pass.ini"
: *** LOG ON TO THE REMOTE PC ***
:connecting
if "%use%"=="yes" goto customlogon
net use \\%targetpc%\ipc$
goto ipcstatus
:customlogon
echo.
echo Using provided login information
net use \\%targetpc%\ipc$ /user:%logon% %pass%
:: *** CHECK TO SEE IF THE IPC NULL SESSION WAS ESTABLISHED ***
:: *** Getrennt is german for disconencted ***
:IPCSTATUS
set ipc=
for /f "tokens=1,*" %%i in ('net use^|find /i "\\%targetpc%\ipc$"') do @set
ipc=%%i
if "%ipc%"=="OK" goto sharecheck
if "%ipc%"=="Getrennt" goto sharecheck
if "%ipc%"=="Disconnected" goto sharecheck
if "%ipc%"=="" goto drivefail
echo Fail under IPCSTATUS
goto end
:: *** READ REMOTE PC'S SHARES AND WORK OUT WHICH DRIVE NT LIVES
ON *** @@
:SHARECHECK
echo Checking share access on %targetpc%
:: FOR /F "tokens=2* delims= " %%A IN ('REG QUERY
"HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRoot" \\%targetpc%')
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" \\%targetpc%')
DO SET folder=%%D
:: FOR /F "tokens=2 delims=:\" %%G IN ('REG QUERY
"HKLM\software\Microsoft\Windows\CurrentVersion\ProgramFilesDir" \\%targetpc%')
DO SET progfiles=%%G
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY
"\\%targetpc%\HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v
SystemRoot') 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
"\\%targetpc%\HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v
SystemRoot') DO SET folder=%%D
FOR /F "tokens=2 delims=:\" %%G IN ('REG QUERY
"\\%targetpc%\HKLM\software\Microsoft\Windows\CurrentVersion" /v
ProgramFilesDir') DO SET oprogfiles=%%G
:: set progfiles for the old VNC version
set progfiles=%oprogfiles%\Orl\VNC
if "%flav%"=="/realb4" set progfiles=%oprogfiles%\RealVNC\VNC4
Echo Querying remote PC %targetpc% registry to locate the start menu. Please
wait.
FOR /F "tokens=1* delims=:\" %%C IN ('REG QUERY
"\\%targetpc%\HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders" /v "Common Programs"') DO SET commonprogs=%%D
set startpath=\\%targetpc%\%remotetarget%$\%commonprogs%
:: don't use quotes on the progfiles variable, it gets upset! :-)
echo Windows (on machine %targetpc%) is on drive %remotetarget% in %folder% and
VNC will be
echo installed into %remotetarget%:\%progfiles% on %targetpc%.
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 * Try using the machine's IP address rather than it's name for the target *
Echo ***************************************************************************
echo.
Echo The command was:
echo REG QUERY "\\%targetpc%\HKLM\Software\Microsoft\Windows NT\CurrentVersion"
/v SystemRoot
echo.
echo Check that you are using REG version 3 (included in XP system) and not an
earlier edition.
goto cleanup
:: *** MAKE A LINK TO THE REMOTE PC AND RECREATE DRIVE SHARE IF
NECESSARY ***
:netuse
if exist \\%targetpc%\%remotetarget%$\*.* goto installcheck
echo The %remotetarget%$ share was unavailable. Attempting to recrate it.
echo rmtshare \\%targetpc%\%remotetarget%$=%remotetarget%:\
rmtshare \\%targetpc%\%remotetarget%$=%remotetarget%:\
if exist \\%targetpc%\%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 \\%targetpc% query winvnc^|find /i
"state"') do @set vncstate=%%i
if "%vncstate%"=="RUNNING" (echo VNC3 is running on %targetpc%.&goto
stopservice)
if "%vncstate%"=="" (echo The VNC3 service is not active on %targetpc%.
Continuing with script.&goto :vnc4state)
if "%vncstate%"=="STOPPED" goto deleteservice
if "%vncstate%"=="STOP_PENDING" echo *** WARNING! Service has hung on stop.
Suggest remote reboot or pskill. Script will now end *** & goto end
echo VNC3 Fail on service state?
:vnc4state
for /f "tokens=4 delims= " %%i in ('sc \\%targetpc% query winvnc4^|find /i
"state"') do @set vnc4state=%%i
if "%vnc4state%"=="RUNNING" (echo VNC4 is running on %targetpc%.&goto
stopservice)
if "%vnc4state%"=="" (echo The VNC4 service is not active on %targetpc%.
Continuing with script.&goto :choosevnc)
if "%vnc4state%"=="STOPPED" goto deleteservice
if "%vnc4state%"=="STOP_PENDING" echo *** WARNING! VNC4 service has hung on
stop. Suggest remote reboot or pskill. Script will now end *** & goto end
echo VNC4 Fail on service state?
goto end
:stopservice
Echo Stopping the WinVNC service on %targetpc%.
sc \\%targetpc% STOP winvnc :: > nul
sc \\%targetpc% STOP winvnc4 :: > nul
echo. Stop pending
timeout 8
:deleteservice
Echo Deleting the WinVNC service on %targetpc%.
sc \\%targetpc% DELETE winvnc
sc \\%targetpc% DELETE winvnc4
Echo Deleting previous VNC registry keys from %targetpc%.
reg delete \\%targetpc%\HKLM\software\orl\winvnc3 /f > nul
reg delete \\%targetpc%\HKU\.Default\Software\Orl /f > nul
reg delete \\%targetpc%\HKLM\software\microsoft\windows\currentversion\run /v
WinVNC /f > nul
reg delete \\%targetpc%\HKLM\software\realvnc\WinVNC4 /f > nul
:: *** CHOOSE THE VNC FLAVOUR AND INSTALL AS NECESSARY ***
:choosevnc
set targetpath="\\%targetpc%\%remotetarget%$\%progfiles%"
if "%remove%"=="yes" goto removevnc
if "%reg%"=="yes" goto regonly
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% from %currentpath%\%flav%.
set copycmd=/y
echo *** About to mess about with VNChooks ***
if exist "%targetpath%\vnchooks.dll" rename "%targetpath%\vnchooks.dll"
vnchooks.old
if exist "%targetpath%\vnchooks.old" del "%targetpath%\vnchooks.old"
if "%flav%"=="/realb4" (
xcopy "%currentpath%\%flav%\*.dll" %targetpath% /f /r /v
xcopy "%currentpath%\%flav%\*.exe" %targetpath% /f /r /v
)
if NOT "%flav%"=="/realb4" (
xcopy "%currentpath%\%flav%\v*.dll" %targetpath% /f /r /v
xcopy "%currentpath%\%flav%\w*.*" %targetpath% /f /r /v
if exist "%currentpath%\%flav%\oth*.dll" xcopy
"%currentpath%\%flav%\oth*.dll" %targetpath% /f /r /v
if exist "%currentpath%\%flav%\om*.dll" xcopy
"%currentpath%\%flav%\om*.dll" "\\%targetpc%\%remotetarget%$\%folder%\system32"
/f /r /v
)
:: AD authenticated DLLs for UltraVNC
echo AD
if exist "%currentpath%\%flav%\au*.dll" xcopy "%currentpath%\%flav%\au*.dll"
%targetpath% /f /r /v
if "%macrep%"=="yes" xcopy "%currentpath%\common\MyDetails.exe"
"\\%targetpc%\%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
goto whatconfig
:regonly
echo ******************************************************************
Echo * Not updating client files - only the registry. *
Echo * This may be used with the /config option for more flexibility. *
echo ******************************************************************
:whatconfig
:: *** 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 *
*
echo * Fastpush will check it's own folder for a config file first and then
check *
echo * a listed path second.
*
echo
*******************************************************************************
timeout 10
echo.
Echo Cross your fingers! :-)
Echo.
if exist "%configfile%" goto infolder
if exist "%currentpath%\%configfile%" goto frompath
Echo Error on path checker
goto end
:infolder
echo Using : regini -m \\%targetpc% "%configfile%"
regini -m \\%targetpc% "%configfile%"
timeout 10
goto newpass
:frompath
echo Using : regini -m \\%targetpc% "%currentpath%\%configfile%"
regini -m \\%targetpc% "%currentpath%\%configfile%"
timeout 10
goto newpass
:: *** INSTALL THE DEFAULT VNC SETTINGS ***
:defaultvnc
Echo Installing the default settings for VNC into the remote registry. Please
wait.
if "%flav%"=="/realb4" (
Echo regini -m \\%targetpc% "%currentpath%\common\vnc4.ini"
regini -m \\%targetpc% "%currentpath%\common\vnc4.ini" > nul
)
if NOT "%flav%"=="/realb4" (
Echo regini -m \\%targetpc% "%currentpath%\common\machine.ini"
regini -m \\%targetpc% "%currentpath%\common\machine.ini" > nul
)
:: *** Check what flavour of VNC and install any REG tweaks if
required ***
if "%flav%"=="vnc9" regini -m \\%targetpc%
"%currentpath%\common\vnc9nopaper.ini"
if "%warning%"=="yes" regini -m \\%targetpc% "%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\%targetpc%.ini" regini -m \\%targetpc%
"%currentpath%\common\%targetpc%.ini" > nul
:newpass
if NOT "%passflag%"=="yes" goto :installhelper
Echo *** Using command line specified VNC password ***
Echo *** This will override any set in a custom ini file ***
regini -m \\%targetpc% "%fplocation%\%targetpc%pass.ini"
del "%fplocation%\%targetpc%pass.ini"
goto installhelper
:installhelper
:: *** THE INST ROUTINE INSTALLS THE VNC SERVICE AND HELPER ***
if "%flav%"=="/realb4" goto installvnc4
Echo.
Echo Installing WinVNC to %remotetarget%:\%progfiles%
:: set if you want the service to be a manual start - change auto to manual
if "%service%"=="yes" SC \\%targetpc% create WinVNC binpath=
"%remotetarget%:\%progfiles%\WinVNC.exe -service" type= own type= interact
start= auto
if "%service%"=="no" SC \\%targetpc% create WinVNC binpath=
"%remotetarget%:\%progfiles%\WinVNC.exe -service" type= own type= interact
start= demand
if exist "\\%targetpc%\%remotetarget%$\%oprogfiles%\realVNC\vnc4\*.*" (
echo Deleting VNC4 from %oprogfiles%\realVNC\Vnc4
rd "\\%targetpc%\%remotetarget%$\%oprogfiles%\realVNC" /s /q
)
:: *** 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.
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>
%currentpath%\path.tmp
copy "%currentpath%\common\helper.ini" + "%currentpath%\path.tmp"
"%currentpath%\helper.tmp" > nul
regini -m \\%targetpc% "%currentpath%\helper.tmp"
del "%currentpath%\*.tmp"
goto startserver
:installvnc4
Echo Installing WinVNC to %remotetarget%:\%progfiles%
if exist "\\%targetpc%\%remotetarget%$\%oprogfiles%\orl\vnc\*.*" (
Echo Deleting old VNC installation.
rd "\\%targetpc%\%remotetarget%$\%oprogfiles%\orl" /s /q
)
:: set if you want the service to be a manual start - change auto to manual
if "%service%"=="yes" (
SC \\%targetpc% create WinVNC4 binpath=
"%remotetarget%:\%progfiles%\WinVNC4.exe -service" type= own type= interact
start= auto
SC \\%targetpc% start winvnc4
goto makeshorts
)
if "%service%"=="no" SC \\%targetpc% create WinVNC4 binpath=
"%remotetarget%:\%progfiles%\WinVNC4.exe -service" type= own type= interact
start= demand
:startserver
:: *** FIRE UP THE SERVICE ***
Echo Attempting to start the service.....
if "%service%"=="yes" sc \\%targetpc% start winvnc
if "%service%"=="no" echo.& Echo Fastpush will start the remote WinVNC service,
but it will not survive a reboot. & sc \\%targetpc% start winvnc
:makeshorts
:: *** SHORTCUT CREATION ROUTINE ***
Echo.
if "%shortcut%"=="no" echo Skipped Start Menu Shortcut Creation & goto sucess
if "%shortcut%"=="yes" echo Starting Start Menu Shortcut Creation
Echo.
Echo Script will attempt to create VNC icons under:
echo '%startpath%\VNC'.
if exist "%startpath%\VNC" rd "%startpath%\VNC" /q /s | Echo Deleted existing
VNC start menu options.
:: *** Read the reg and work out where the All Users' desktop is
***
FOR /F "tokens=1* delims=:\" %%C IN ('REG QUERY
"\\%targetpc%\HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders" /v "Common Desktop"') DO SET commondesk=%%D
set remotedesk=\\%targetpc%\%remotetarget%$\%commondesk%
:: *** CREATE A BATCH FILE TO CREATE SHORTCUTS ON REMOTE PC ***
if exist "\\%targetpc%\%remotetarget%$\%folder%\icons.cmd" del /q
"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
if not exist "\\%targetpc%\%remotetarget%$\%folder%\system32\shortcut.exe" copy
"%fplocation%\utils\shortcut.exe"
"\\%targetpc%\%remotetarget%$\%folder%\system32"
echo @echo off>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
if NOT "%flav%"=="/realb4" (
if exist "%startpath%\RealVNC\*.*" rd "%startpath%\RealVNC" /s /q
if not exist "%startpath%\VNC" mkdir "%startpath%\VNC"
if not exist "%startpath%\VNC\VNC Server" mkdir "%startpath%\VNC\VNC
Server"
if not exist "%startpath%\VNC\VNC Viewer" mkdir "%startpath%\VNC\VNC
Viewer"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncviewer.exe" -n
"%remotetarget%:\%commonprogs%\VNC\Run VNC Viewer" -d
"%remotetarget%:\%progfiles%">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\Run VNC Server" -d
"%remotetarget%:\%progfiles%">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Add New Client" -d
"%remotetarget%:\%progfiles%" -a
"-connect">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Register VNC Server Service" -d
"%remotetarget%:\%progfiles%" -a
"-install">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Run Service Helper" -d
"%remotetarget%:\%progfiles%" -a
"-servicehelper">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Show About Box" -d
"%remotetarget%:\%progfiles%" -a
"-about">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Show Default Properties" -d
"%remotetarget%:\%progfiles%" -a
"-defaultsettings">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Show User Properties" -d
"%remotetarget%:\%progfiles%" -a
"-settings">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Server\Unregister VNC Service" -d
"%remotetarget%:\%progfiles%" -a
"-remove">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncviewer.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Viewer\Listening VNC Viewer" -d
"%remotetarget%:\%progfiles%" -a "-listen"
>>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncviewer.exe" -n
"%remotetarget%:\%commonprogs%\VNC\VNC Viewer\Register Viewer with saved
sessions" -d "%remotetarget%:\%progfiles%" -a
"-register">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
)
if "%flav%"=="/realb4" (
if exist "%startpath%\VNC\*.*" rd "%startpath%\VNC" /s /q
if not exist "%startpath%\RealVNC" mkdir "%startpath%\RealVNC"
if not exist "%startpath%\RealVNC\VNC Server 4 (Service-Mode)" mkdir
"%startpath%\RealVNC\VNC Server 4 (Service-Mode)"
if not exist "%startpath%\RealVNC\VNC Server 4 (User-Mode)" mkdir
"%startpath%\RealVNC\VNC Server 4 (User-Mode)"
if not exist "%startpath%\RealVNC\VNC Viewer 4" mkdir
"%startpath%\RealVNC\VNC Viewer 4"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncconfig.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (Service-Mode)\Configure
VNC Service" -d "%remotetarget%:\%progfiles%" -a
"-service">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc4.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (Service-Mode)\Register VNC
Service" -d "%remotetarget%:\%progfiles%" -a
"-register">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc4.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (Service-Mode)\Start VNC
Service" -d "%remotetarget%:\%progfiles%" -a
"-start">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc4.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (Service-Mode)\Stop VNC
Service" -d "%remotetarget%:\%progfiles%" -a
"-stop">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc4.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (Service-Mode)\Unregister
VNC Service" -d "%remotetarget%:\%progfiles%" -a
"-unregister">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncconfig.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (User-Mode)\Configure
User-Mode Settings" -d "%remotetarget%:\%progfiles%" -a
"-user">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\winvnc4.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Server 4 (User-Mode)\Run VNC Server"
-d "%remotetarget%:\%progfiles%" -a
"-noconsole">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncviewer.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Viewer 4\Run Listening VNC Viewer"
-d "%remotetarget%:\%progfiles%" -a
"-listen">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
echo shortcut -f -t "%remotetarget%:\%progfiles%\vncviewer.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\VNC Viewer 4\Run VNC Viewer" -d
"%remotetarget%:\%progfiles%" -a
"">>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
)
:: *** IF REPORTING OPTION IS ON, CREATE A DESKTOP LINK SO USERS CAN FIND
OUT WHAT BOX THEY'RE USING ***
if "%macrep%" NEQ "yes" goto runicons
echo shortcut -f -t "%remotetarget%:\%folder%\system32\mydetails.exe" -n
"%remotetarget%:\%commondesk%\My Details"
>>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
if "%flav%"=="/realb4" echo shortcut -f -t
"%remotetarget%:\%folder%\system32\mydetails.exe" -n
"%remotetarget%:\%commonprogs%\RealVNC\My Details"
>>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
if not "%flav%"=="/realb4" echo shortcut -f -t
"%remotetarget%:\%folder%\system32\mydetails.exe" -n
"%remotetarget%:\%commonprogs%\VNC\My Details"
>>"\\%targetpc%\%remotetarget%$\%folder%\icons.cmd"
:: *** EXECUTE BATCH FILE ON REMOTE COMPUTER ***
:runicons
Echo.
if "%psexec%"=="yes" psexec \\%targetpc% "%remotetarget%:\%folder%\icons.cmd"
if NOT "%psexec%"=="yes" xcmd \\%targetpc% "%remotetarget%:\%folder%\icons.cmd"
:: xcmd not does seem as reliable for some reason - investigate
:: xcmd \\%targetpc% "%remotetarget%:\%folder%\icons.cmd"
goto rem%errorlevel%
:: goto :sucess
:rem0
Echo.
Echo Icons command excuted on remote machine %targetpc%
echo del "\\%targetpc%\%remotetarget%$\%folder%\icons.cmd" /q
goto sucess
:rem1
Echo.
ECHO *** WARNING! ***
Echo Icons command failed!! Investigate %targetpc%.
goto sucess
:rem-1
Echo.
ECHO *** WARNING! ***
Echo Icons command failed!! Investigate %targetpc%.
goto sucess
:rem128
Echo.
ECHO *** WARNING! ***
Echo Xcmd service unable to be installed. Investigate %targetpc%.
Echo Shortcuts were not created / updated.
goto sucess
echo End of shortcut creation scheme
goto sucess
:FORCECHECK
if not "%force%"=="yes" goto drivefail
rmtshare \\%targetpc%\%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 %targetpc%.
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 15
echo Files and host directory will be deleted from %targetpath%
echo.
Echo Start menu shortcuts will be removed from :
echo "%startpath%".
if exist "%startpath%\vnc" rd "%startpath%\vnc" /q /s | Echo Deleted existing
VNC shortcuts.
if exist %targetpath% rd %targetpath% /q /s | Echo %targetpath% folder removed.
if "%flav%"=="/realb4" if exist %otargetpath%\orl\vnc rd %otargetpath%\orl\vnc
/q /s | Echo %targetpath% folder removed.
if exist "\\%targetpc%\%remotetarget%$\%folder%\system32\omnithread*.dll" del
"\\%targetpc%\%remotetarget%$\%folder%\system32\omnithread*.dll" /s
FOR /F "tokens=1* delims=:\" %%C IN ('REG QUERY
"\\%targetpc%\HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders" /v "Common Desktop"') DO SET commondesk=%%D
set remotedesk=\\%targetpc%\%remotetarget%$\%commondesk%
if exist "\\%targetpc%\%remotetarget%$\%commondesk%\my details.lnk" echo
Deleting the My Details icon from the desktop & del /q
"\\%targetpc%\%remotetarget%$\%commondesk%\my details.lnk"
Echo Removing \\%targetpc%\ipc$ link.
net use \\%targetpc%\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
:UTILFAIL
echo.
echo
*****************************************************************************
Echo * Error: A utility critical to the operation of FastPush could not be
found *
Echo * Please install this executeable into the fastpush\utils folder
*
echo
*****************************************************************************
set logvalue=noutil
if "%logit%"=="yes" goto logging
goto END
:PWDFAIL
echo.
echo
*****************************************************************************
Echo * Error: You specified /pwd to use a custom vnc password. However you did
*
Echo * not provide a password after using this switch. Please try again.
*
echo
*****************************************************************************
set logvalue=nopwd
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 \\%targetpc%\ipc$ /del > nul
if exist %netdrv%: net use %netdrv%: /del > nul
echo ------------------------------------------------------------
echo Fastpush to '%targetpc%'.
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 Create Start Menu links : %shortcut%
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 %currentpath%\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% : %targetpc% : %flav% was
installed to %targetpc%. > "%currentpath%\results.tmp"
if "%logvalue%"=="noip" echo %zdate% : %zclock% : %targetpc% : Error:
%targetpc% not pingable. Check TCP/IP. > "%currentpath%\results.tmp"
if "%logvalue%"=="noreg" echo %zdate% : %zclock% : %targetpc% : NT system
folder not found. > "%currentpath%\results.tmp"
if "%logvalue%"=="noshare" echo %zdate% : %zclock% : %targetpc% : $Admin share
on %targetpc% unavailable. Check shares. > "%currentpath%\results.tmp"
if "%logvalue%"=="drivefail" echo %zdate% : %zclock% : %targetpc% : Failed to
logon to %targetpc%. Check logon/shares. > "%currentpath%\results.tmp"
if "%logvalue%"=="killed" echo %zdate% : %zclock% : %targetpc% : VNC service
and files were removed. > "%currentpath%\results.tmp"
if "%logvalue%"=="novnccmd" echo %zdate% : %zclock% : %targetpc% : VNC command
file not found. Check path variable > "%currentpath%\results.tmp"
if "%logvalue%"=="nocmd" echo %zdate% : %zclock% : %targetpc% : No valid
command line options were found > "%currentpath%\results.tmp"
if "%logvalue%"=="noutil" echo %zdate% : %zclock% : %targetpc% : No valid
command line options were found > "%currentpath%\results.tmp"
if "%logvalue%"=="nopwd" echo %zdate% : %zclock% : %targetpc% : Specified /pwd
but did not supply a password > "%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
goto end
:: *** INSERT CALLED PROCEDURES HERE ***
:: *** They won't be run unless called directly ***
:chkcount
:: *** Pick each item from the scan array ***
for /f "tokens=%1 delims= " %%p in ('echo %scan%') do @call :chkutil %%p
goto :eof
:chkutil
:: *** Check for the existance of each component ***
if "%missing%"=="yes" goto :eof
:: if exist %currentpath%\utils\%1.exe echo %1 okay.
if not exist %currentpath%\utils\%1.exe echo %1 not found. Please install %1 in
%currentpath%\utils. & set missing=yes
goto :eof
:: *** END OF THE LINE ***
:END
set user=
set pass=
set vncpass=
if "%pushd%"=="1" POPD
if exist "%fplocation%\%targetpc%pass.ini" del "%fplocation%\%targetpc%pass.ini"
:: Echo Restoring old path to "%oldpath%".
set path=%oldpath%