我正在创建一个小程序来帮助Windows 7中臭名昭着的Windows Update失败!我正在使用的是批量但是出于某种原因“回声”。没有显示空白行。有任何想法吗。这是我的代码
@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
答案 0 :(得分:2)
评论中已经回答了,但我试着在这里总结一下。
使用echo.
是一个不错的选择,因为当当前目录中存在名为echo
且没有扩展名的文件时,它会失败。
它比echo(
慢〜10倍,因为它始终扫描当前目录
当您从一个非常慢的驱动器(如网络共享)启动批处理时,这会变得更糟。
正如Aacini所提到的,你可以使用许多其他工作变量来获得空行
echo/
echo:
echo\
echo,
echo;
echo=
echo(
但是如果你还希望能够输出一个可以包含任何内容并且也允许为空的变量,那么你应该使用echo(
,因为这似乎是唯一安全的变体。
set "var=any content like /? ON ..\..\windows\system32\calc.exe etc"
echo(!var!