echo. is not working?

≯℡__Kan透↙ 提交于 2020-01-05 14:25:14

问题


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

回答1:


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!


来源:https://stackoverflow.com/questions/32872506/echo-is-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!