我有這個片段的批處理文件在它:批處理文件|符號:插入空格無緣無故
systeminfo|findstr /B "Host Name:"|findstr /C:"COMPNAME-SET"
if %ERRORLEVEL% EQU 0 (
echo This computer is either a test machine or has not had it's name configured yet. Continuing will run the script in test mode.
pause
)
我不知道爲什麼,但前行不起作用。輸出是這樣的:。
Z:\>systeminfo | findstr /B "Host Name:" | findstr /C:"IGSWIDWB-SET"
The syntax of the command is incorrect.
Z:\>
有它的「標誌後,似乎是一個多餘的空間,我以前用的是管道和命令之間的空間,但我在試圖解決這個錯誤,把他們趕走它沒有區別我已經確定文件是Windows格式的Windows風格的字符,我不知道該怎麼做。這是我正在使用的標準批處理腳本。
此代碼讓我如果它是我開發的自動化安裝腳本中的筆記本電腦或臺式機,則主機名具有特定的協議,並且它將根據此步驟通過一組安裝進行導航
任何人都知道什麼是錯的? 謝謝!
爲了響應[name here],這裏是在它之前執行的代碼(以及在它之後執行的代碼);然而,我修改了這些詞,所以它不是什麼明顯的。我在一個喜歡不分享內部文檔的組織工作,但不介意我是否將其混淆。失敗的部分在第一個systeminfo所在的行上。
::@echo off
setlocal
set BATDIR=%~dp0%
set SCRIPTVER=3.2
cls
set SUBDEPARTMENT=false
if not [%1]==[] (
if "%1" EQU "/help" (
echo Calling For Help.
CALL :HELP
goto :EOF
)
if "%1" EQU "/SUBDEPARTMENT" (
set SUBDEPARTMENT=true
echo Set SUBDEPARTMENT options to true.
::echo SUBDEPARTMENT Switch does not work on this version of the script. ::CD VERSION ONLY :: Continuing without.
echo.
goto CONTINUE
)
)
:Continue
color 0B
echo XXXX AutoInstaller Script for Windows 7/XP (x86/amd64)
echo Version %SCRIPTVER% - Build Date: 11/14/2012
echo Estimated Install Time: 80(Core) to 180(SUBDEPARTMENT) minutes
echo Computer will reboot to phase 2 once completed.
echo A log file for this script can be found at %USERPROFILE%\AutoInstallerLog.txt
echo ---------------------------------------------------------------
echo Preparing System...
echo Auto Install Log, generated on: > %USERPROFILE%\AutoInstallerLog.txt
echo AutoInstaller Script Version: %SCRIPTVER% >> %USERPROFILE%\AutoInstallerLog.txt
DATE /T >> %USERPROFILE%\AutoInstallerLog.txt
echo This log file reflects what steps completed in the ASI script. It does not mean they completed correctly so please make sure that all software is installed correctly!
echo Make sure the computer has been renamed to match the type [e.g. COMPUTER_PROTOCOL]. Make sure it has also been rebooted it so that it takes effect.
echo SystemInfo Output: >> %USERPROFILE%\AutoInstallerLog.txt
systeminfo >> %USERPROFILE%\AutoInstallerLog.txt
::Setting script parameters
echo.
echo Configuring script parameters.
::Check if it's a test machine
echo systeminfo^|findstr /B "Host Name:"^|findstr /C:"TESTCOMP_NAME"
systeminfo|findstr /B "Host Name:"|findstr /C:"TESTCOMP_NAME"
if %ERRORLEVEL% EQU 0 (
echo This computer is either a test machine or has not had it's name configured yet. Continuing will run the script in test mode.
pause
set TestComp=1
::TestOS
systeminfo|findstr /C:"XP Professional"
if %ERRORLEVEL% EQU 0 (
set OS=XP
goto :finishTestOS
)
systeminfo | findstr /C:"7 Enterprise"
if %ERRORLEVEL% EQU 0 (
set OS=7
goto :finishTestOS
)
:finishTestOS
set STYLE=workstation
goto :AdminCheck
)
::Debug Statement:
echo NEXT PArT!!! LINE 67
::::OS Version
:getOS
systeminfo|findstr /C:"XP Professional"
if %ERRORLEVEL% EQU 0 (
set OS=XP
goto :finishOS
)
systeminfo|findstr /C:"7 Enterprise"
if %ERRORLEVEL% EQU 0 (
set OS=7
goto :finishOS
)
:finishOS
echo This system is running Windows %OS%.
::Get Form Factor
:getStyle
systeminfo | findstr /B "Host Name:" | findstr /C:"WORKSTATION_PROTOCOL"
if %ERRORLEVEL% EQU 0 (
set STYLE=laptop
) else (
set STYLE=workstation
)
:finishStyle
echo This system is a %STYLE%.
if not defined STYLE (
echo System style not configured correctly. The name of the computer likely does not follow protocol, it must have PROTOCOLS in it.
goto :ERROREND
)
if not defined OS (
echo OS not detected properly. The script may need to be updated to detect new versions of Windows.
goto :ERROREND
)
我試了兩個管道之前和之後的空間,它工作正常。即使在報價後有2個空格字符。 – Laf
我猜想那裏有一個看不見的角色。嘗試重新輸入相關線路。 –
我重新輸入它並沒有修復它。 (還沒有閱讀發佈的其他答案)。但是,感謝您的意見:) – Mgamerz