I can't see the var from an echo
Posted: 16 Oct 2022 23:23
I have an echo on line 174 that I don't see when I run the batch script.
I do have:
setlocal EnableDelayedExpansion
On line 94
This is what it looks like when I run the script: This is my batch file:
I do have:
setlocal EnableDelayedExpansion
On line 94
This is what it looks like when I run the script: This is my batch file:
Code: Select all
@echo Off
:: The following code will make sure this is running as Administrator
(
>nul 2>&1 %__APPDIR__%net.exe session
) || (
echo Set UAC = CreateObject^("Shell.Application"^) > "%tmp%\uac.vbs"
echo UAC.ShellExecute "%~snx0", "%*", "%~sdp0", "runas", 1 >> "%tmp%\uac.vbs"
) && (
"%tmp%\uac.vbs" && exit /b
)
if exist "%tmp%\uac.vbs" del /f /q "%tmp%\uac.vbs"
:: The Above code will make sure this is running as Administrator
:: This will install UltraVNC on a PC remotely.
::
:: Disclaimer: Use at your own risk. I have tested this on my PC running XP Pro.
::
:: To run: Copy all required files listed below to the remote PC
:: Run this Batch file on the remote PC
:: Wait for it to complete. This could take a couple minutes.
:: View remote PC with the new VNC viewer.
::
:: Note: If the VNC service is not running you will get an error.
:: You should ignore it.
:: Note: This does produce a screen that says
:: "Warning: This machine has no default password set"
:: You should ignore it.
:: Note: This will re-boot. When it comes up the password and all the settings will
:: be good to go if you followed the instructions below.
:: Required Files: The following files must be in the same folder.
:: VNC_UltraVNC-102-Setup.exe
:: VNCsaveinf.inf
:: VNCsetup.reg
:: SecureVNCPlugin64.dsm (ver. 1.1.8) Until ver. 1.2.1 is fixed
:: rc4.key
:: Thanks to extremesanity on the ULtraVNC forum for some of these instructions.
:: I wanted to put all instructions in one place.
:: Note: You can get VNC_UltraVNC-102-Setup.exe at:
:: http://sourceforge.net/project/showfiles.php?group_id=63887
:: Note: You can get VNCsaveinf.inf & VNCsetup.reg by running the following:
:: 1. Run on a local PC the exe with the command "UltraVNC-101-Setup.exe /saveinf=c:\VNCsaveinf.inf"
:: This will save the main config file to a path of your choosing.
:: 2. Go through the setup changing config settings to how you want it installed (language, program path, etc).
:: Make sure to make the following selections
:: UltraVNC Server
:: Mirror Driver
:: DSM Encryption Plugin
:: and on the additional tasks page select Register UltraVNC as service
:: DO NOT select Start or restart UltraVNC Service
:: select Configure MS-Logon II (If you want it)
:: DO NOT select Configure Admin Properties
:: DO NOT select Clean old VNC registry keys
:: Don't worry about the ACL settings, we will change those in a bit
:: 3. When it's finished go to the start menu and click on UltraVNC > UltraVNC Server
:: Click on the show default settings.
:: Make all the changes you want applied across all computers here.
:: The password, MS Logon groups, and misc settings need to be set.
:: 4. If you don't have the file rc4.key from a previous install create one by:
:: Putting a check mark into the box DSM Plugin.
:: Select the plugin.
:: Select Config.
:: Select 128 bit
:: Select Gen Key
:: 5. If you want to use MS-Logon II:
:: In DOS in c:\program files\ultravnc
:: Type in MSLogonACL.exe /e c:\someaclconfigfile.acl - this will create your ACL file
:: close DOS
:: Note: I have not included this in the install bat file. I have not used it yet.
:: Someone else might be able to comment on how to use it.
:: 6. Start > run > regedit
:: Export the hkey_local_machine > software > ORL key to reg file VNCsetup.reg
:: 7. Edit the VNCsaveinf.inf file you created in steps 1 & 2 above,
:: and put this in for the acl and reg paths
:: AclFile=c:\PathToThisFolder\someaclfile.txt
:: PropertiesFile=c:\PathToThisFolder\VNCsetup.reg
:: Note: You can get SecureVNCPlugin64.dsm (ver. 1.1.8) at:
:: http://prdownloads.sourceforge.net/ultravnc/UltraVnc-101-Setup.zip?download
:: 1. Install the above file only selecting SecureVNCPlugin64.dsm
:: 2. After saving the SecureVNCPlugin64.dsm you can delete the rest that was installed.
::
:: Save the required files listed above to a scratch folder.
:: The files are all created. Shut down VNC. You can uninstall it if you don't need it.
::
@echo off
Set FileName=VNC UltraVNC_1_3_81_X64_Setup.exe
set wkdir=%~dp0
(set lf=^
%= creates a line feed, do not alter =%
)
setlocal EnableDelayedExpansion
::net use z: \\yourserver\sharename
::copy "z:\FolderName" "C:\TEST_BACKUP_FOLDER"
:FileCopied
set "file="
if not exist "%FileName%" (
set "file=!file!!lf! ? %FileName%"
xcopy /y /f "\\DOCFXITLT10\Dnload2\9xAddons\VNC_Install\%FileName%" "%wkdir%"
IF NOT ERRORLEVEL 1 GOTO FileCopied)
if not exist "VNCsetup.inf" (
set "file=!file!!lf! ? VNCsetup.inf"
xcopy /y /f "\\DOCFXITLT10\Dnload2\9xAddons\VNC_Install\VNCsetup.inf" "%wkdir%"
IF NOT ERRORLEVEL 1 GOTO FileCopied)
if not exist "VNCsetup.reg" (
set "file=!file!!lf! ? VNCsetup.reg"
xcopy /y /f "\\DOCFXITLT10\Dnload2\9xAddons\VNC_Install\VNCsetup.reg" "%wkdir%"
IF NOT ERRORLEVEL 1 GOTO FileCopied)
if not exist "SecureVNCPlugin64.dsm" (
set "file=!file!!lf! ? SecureVNCPlugin64.dsm"
xcopy /y /f "\\DOCFXITLT10\C\Programs\UltraVNC\SecureVNCPlugin64.dsm" "%wkdir%"
IF NOT ERRORLEVEL 1 GOTO FileCopied)
if not exist "rc4.key" (
set "file=!file!!lf! ? rc4.key"
xcopy /y /f "\\DOCFXITLT10\Dnload2\9xAddons\VNC_Install\RC4.KEY" "%wkdir%"
IF NOT ERRORLEVEL 1 GOTO FileCopied)
if defined file (
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
echo 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커
echo ? The files ...!file!
echo ?
echo ? ... do not exist in this directory.
echo ?
echo ? Move the above files into %wkdir%
echo ?
echo ?
echo ?
echo ? Press any key to close this window
echo ?
echo 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸
Pause > Nul
) Else (
Echo.
Echo.
Echo.
echo 旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커
echo ?
echo ? Please ignore all messages...
echo ?
echo ?
echo ? Please wait. This does take a couple minutes ...
echo ?
echo 읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸
netsh advfirewall firewall add rule name="UltraVNCTCP5909" dir=in action=allow protocol=TCP localport=5909
netsh advfirewall firewall add rule name=UltraVNCServer dir=in action=allow program="C:\Programs\UltraVNC\winvnc.exe" enable=yes
:: To disable ForceGuest security setting:
::ForceGuest is disabled automatically in a domain environment
:: For workgroup computers,
:: Open GPEDIT.MSC
:: Browse through Computer Configuration
:: Windows Settings
:: Security Settings
:: Local Policies
:: Security Options
:: Select Network Access: Sharing and Security Model for Local Accounts.
:: Change this to Classic.
net stop WinVNC >nul
net stop uvnc_service >nul
sc delete uvnc_service >nul
If NOT exist "C:\Programs\UltraVNC" Md "C:\Programs\UltraVNC" > Nul
::*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Set inffile="%wkdir%VNCsetup.inf" ;I don't see this in the cmd window
echo %inffile% ;I don't see this in the cmd window
echo %wkdir%%FileName% ;I see this in the cmd window just fine
::*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
::start /wait "%wkdir%%FileName%" /loadinf=%inffile% /props="vncsetup.reg" /Very silent
start /wait "%wkdir%%FileName%" /loadinf=%inffile% /Very silent
echo Importing vnc settings...
start /wait regedit /s %wkdir%vncsetup.reg
echo Copy the MSRC plugin...
copy /y "%wkdir%SecureVNCPlugin64.dsm" "C:\Programs\UltraVNC" > Nul
echo 128 Bit encryption key...
copy /y %wkdir%rc4.key "C:\Programs\UltraVNC" > Nul
echo Starting UltraVnc ...
::start /d "C:\Programs\UltraVNC" winvnc.exe -sinstall"
net start uvnc_service
start /d "C:\Programs\UltraVNC" winvnc.exe -servicehelper"
:: If you don't want the links on the desktop
::If exist "C:\Documents and Settings\%DesktopDir%\Desktop\Ultr@VNC Viewer.lnk" Del "C:\Documents and Settings\Gary\Desktop\Ultr@VNC Viewer.lnk"
If exist "C:\Documents and Settings\%DesktopDir%\Desktop\UltraVNC Server.lnk" Del "C:\Documents and Settings\%DesktopDir%\Desktop\UltraVNC Server.lnk"
::%windir%\System32\shutdown.exe -r -t 00
::exit
endlocal
CMD /k
)