回声.不管用? [英] echo. is not working?

查看:49
本文介绍了回声.不管用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个小程序来解决Windows 7中臭名昭著的Windows Update失败!我正在使用的是批处理,但由于某种原因会产生回声".没有显示空行.有任何想法吗.这是我的下面的代码

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

推荐答案

评论中已经回答了,但是我尝试在这里进行总结.

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

使用 echo.是一个错误的选择,因为当当前目录中存在没有扩展名的 echo 文件时,它会失败.
它比 echo(慢大约10倍,因为它总是扫描当前目录.
当您从速度非常慢的驱动器(例如网络共享)开始批处理时,情况可能会变得更糟.

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.

正如Aacini所提到的,您可以将许多其他可行的变体用于空行

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

echo/
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!

这篇关于回声.不管用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆