1

I'm creating A Small Program To Help With The Infamous Windows Update Fail in Windows 7! What I'm Using Is A Batch But For Some Reason The "echo." isn't showing blank lines. Any Ideas. Here's my code below

@echo off

:checkPrivileges 
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) 

:getPrivileges 
if '%1'=='ELEV' (shift & goto gotPrivileges)  
ECHO. 
ECHO **************************************
ECHO Invoking Administration Privledges 
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs" 
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs" 
"%temp%\OEgetPrivileges.vbs" 
exit /B 

:gotPrivileges 
::::::::::::::::::::::::::::
:START
::::::::::::::::::::::::::::
setlocal & pushd .
REM Run shell as admin (example) - 
SET ProgFiles86Root=%ProgramFiles(x86)%
IF NOT "%ProgFiles86Root%"=="" GOTO win64
SET ProgFiles86Root=%ProgramFiles%
:win64
CLS                                                        
:::   _    _ _       _   _           _       _       
:::  | |  | |(_)    | | | |         | |     | |      
:::  | |  | |_ _ __ | | | |_ __   __| | __ _| |_ ___ 
:::  | |/\| | | '_ \| | | | '_ \ / _` |/ _` | __/ _ \
:::  \  /\  / | | | | |_| | |_) | (_| | (_| | ||  __/
:::   \/  \/|_|_| |_|\___/| .__/ \__,_|\__,_|\__\___|
::: ======================| |==============FIXER v1.0===============                      
:::                       |_|                      
for /f "delims=: tokens=*" %%A in ('findstr /b ::: "%~f0"') do @echo(%%A
timeout /t 10 >nul
cls
IF EXIST %systemdrive%\winuf.dll (goto second) else goto begin
:begin
echo Thanks For Choosing To Run WinUpdate Fixer
echo.
echo.
echo This Program Will Attempt To Fix Your Windows Update Issues!
echo By Continuing WinUpdate Fixer Will Reset Your Windows Update
:choice
set /P c=Do you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto :fix
if /I "%c%" EQU "N" goto :exit
goto :choice


:exit
echo.
echo.
echo Thanks Anyway!
pause
exit



:fix
REM. > %systemdrive%\winuf.dll
echo.
echo.
echo.
echo *******************************************************************************
echo                            Fixing Windows Update
echo *******************************************************************************
pause

:second
del /q /s /f  %systemdrive%\winuf.dll >nul
echo did the program work
pause
  • 4
    Try with `echo(` If you have some kind of executable called `echo` it will be called when using `echo.` – MC ND Sep 30 '15 at 17:56
  • @MCND Are you sure ? I would say internal commands go first, unless you enter ´echo.exe´ – Marged Sep 30 '15 at 18:54
  • Normally ´echo.´ should work. You might want to try ´echo,´ or ´echo/´. Perhaps echoing a hidden space character works for you, have a look here: http://www.fileformat.info/info/unicode/char/200B/index.htm (basically this means specifying ALT+0200) – Marged Sep 30 '15 at 18:55
  • At which line of your code is the problem? – aschipfl Sep 30 '15 at 19:05
  • 4
    `echo.` for blank lines and `::` for "comments" are the two worst ancient ideas that Batch file users had inherited... You may use `echo/` to leave blank lines and `echo(%var%` when `var` may contain _any string_ (including `/?`). See http://www.dostips.com/forum/viewtopic.php?f=3&t=774 – Aacini Sep 30 '15 at 19:36
  • All of my "echo." always worked before but now are not working. I tried "echo/" and that has seemed to work beautifully! Thank you! – Semaj Rellim Sep 30 '15 at 20:18
  • @Marged internal commands _do not_ go first. Try `type nul>echo` and then `echo.` or even (note a space after dot) `echo. something`. Surprisingly, `echo.something` will work... – JosefZ Oct 01 '15 at 02:36
  • @JosefZ I wrote "they go first unless you enter `echo.exe`". Entering `echo.` when a file `echo` exists is the same and normally executables on Windows have the .exe extension – Marged Oct 01 '15 at 07:41
  • 1
    @Marged Exactly opposite as you wrote: they _do not_ go first _although_ no `.exe` entered. Just only `echo.`. Quod erat demonstrandum_. – JosefZ Oct 01 '15 at 09:10
  • @JosefZ I am talking about this scenario, just run the script. `@echo off copy C:\windows\system32\cacls.exe echo.exe > nul echo here i am echo. echo There should be an empty line above` – Marged Oct 01 '15 at 11:03

1 Answers1

2

It's already answered in the comments, but I try to summarize it here.

Using echo. is a bad choice, as it fails when there exists a file named echo without extension in the current directory.
And it's ~10 times slower than echo( as it always scan the current directory.
When you start your batch from a really slow drive (like a network share) this can get more worse.

As Aacini mentioned you could use many other working variants for an empty line

echo/
echo:
echo\
echo,
echo;
echo=
echo(

But if you also want to be able to output a variable which can contain any content and is also allowed to be empty, you should use echo( as this seems to be the only safe variant.

set "var=any content like /? ON ..\..\windows\system32\calc.exe etc"
echo(!var!
jeb
  • 78,592
  • 17
  • 171
  • 225