怎么用批处理读取含多个空格的字符串

我想把第二行的数据提出来包括空格SERVICE_NAME:AlerterSERVICE_NAME:ALGSERVICE_NAME:AppMgmtSERVICE_NAME:... 我想把第二行的数据提出来包括空格

SERVICE_NAME: Alerter
SERVICE_NAME: ALG
SERVICE_NAME: AppMgmt
SERVICE_NAME: aspnet_state
SERVICE_NAME: AudioSrv
SERVICE_NAME: BITS
SERVICE_NAME: Browser
SERVICE_NAME: CiSvc
SERVICE_NAME: ClipSrv
SERVICE_NAME: COMSysApp
SERVICE_NAME: CryptSvc
SERVICE_NAME: DcomLaunch
SERVICE_NAME: Dhcp
SERVICE_NAME: dmadmin
SERVICE_NAME: dmserver
SERVICE_NAME: Dnscache
SERVICE_NAME: Dot3svc
SERVICE_NAME: EapHost
SERVICE_NAME: EhttpSrv
SERVICE_NAME: ekrn
SERVICE_NAME: Eventlog
SERVICE_NAME: EventSystem
SERVICE_NAME: FastUserSwitchingCompatibility
SERVICE_NAME: FLEXnet Licensing Service
SERVICE_NAME: helpsvc
SERVICE_NAME: HidServ
SERVICE_NAME: hkmsvc
SERVICE_NAME: HTTPFilter
SERVICE_NAME: IDriverT
SERVICE_NAME: ImapiService
SERVICE_NAME: LanmanServer
SERVICE_NAME: lanmanworkstation
SERVICE_NAME: LmHosts
SERVICE_NAME: mnmsrvc
SERVICE_NAME: MSDTC
SERVICE_NAME: MSIServer
SERVICE_NAME: napagent
SERVICE_NAME: NetDDE
SERVICE_NAME: NetDDEdsdm
SERVICE_NAME: Netlogon
SERVICE_NAME: Netman
SERVICE_NAME: Nla
SERVICE_NAME: NtLmSsp
SERVICE_NAME: NtmsSvc
SERVICE_NAME: NVSvc
SERVICE_NAME: ose
SERVICE_NAME: PlugPlay
SERVICE_NAME: PolicyAgent
SERVICE_NAME: ProtectedStorage
SERVICE_NAME: RasAuto
SERVICE_NAME: RasMan
SERVICE_NAME: RDSessMgr
SERVICE_NAME: RemoteAccess
SERVICE_NAME: RemoteRegistry
SERVICE_NAME: RpcLocator
SERVICE_NAME: RpcSs
SERVICE_NAME: RSVP
SERVICE_NAME: SamSs
SERVICE_NAME: Schedule
SERVICE_NAME: seclogon
SERVICE_NAME: SENS
SERVICE_NAME: SharedAccess
SERVICE_NAME: ShellHWDetection
SERVICE_NAME: Spooler
SERVICE_NAME: srservice
SERVICE_NAME: SSDPSRV
SERVICE_NAME: stisvc
SERVICE_NAME: SwPrv
SERVICE_NAME: SysmonLog
SERVICE_NAME: TapiSrv
SERVICE_NAME: TdpaServer
SERVICE_NAME: TermService
SERVICE_NAME: Themes
SERVICE_NAME: TlntSvr
SERVICE_NAME: UMWdf
SERVICE_NAME: upnphost
SERVICE_NAME: UPS
SERVICE_NAME: VSS
SERVICE_NAME: W32Time
SERVICE_NAME: winmgmt
SERVICE_NAME: WmdmPmSN
SERVICE_NAME: Wmi
SERVICE_NAME: WmiApSrv
SERVICE_NAME: wscsvc
SERVICE_NAME: wuauserv
SERVICE_NAME: WZCSVC
SERVICE_NAME: xmlprov
SERVICE_NAME: wang server
在线等,急。
是第二列的 如 wang server
展开
 我来答
睿之锐
2009-07-29 · TA获得超过1269个赞
知道小有建树答主
回答量:809
采纳率:0%
帮助的人:478万
展开全部
保留最前面空格!
@echo off&setlocal Enabledelayedexpansion
if exist "结果.txt" del /q /f /a "结果.txt"
set /p file=请把你要处理的文本文件拖到本窗口或手动输入路径文件名:
set "file=!file:"=!"
for /f "tokens=1,2 delims=:" %%a in ('type "%file%"') do echo %%b>>结果.txt
start 结果.txt&exit

不保留最前面空格!
@echo off&setlocal Enabledelayedexpansion
if exist "结果.txt" del /q /f /a "结果.txt"
set /p file=请把你要处理的文本文件拖到本窗口或手动输入路径文件名:
set "file=!file:"=!"
for /f "tokens=1,2 delims=:" %%a in ('type "%file%"') do set rui=%%b&echo !rui:~1!>>结果.txt
start 结果.txt&exit
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
314ccp
2009-07-30 · TA获得超过5625个赞
知道大有可为答主
回答量:1497
采纳率:0%
帮助的人:2168万
展开全部
@echo off
for /f "delims=" %%i in (a.txt)do call:.,"%%i"
start b.txt&exit
:.
set "str=%~1"
set "str=%str:~14,100%"
echo %str%>>b.txt

其实你不需要懂批处理也可以自己动手完成的!
将SERVICE_NAME: 全部替换成空就可以了。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
千羽之城
2009-07-29 · TA获得超过4510个赞
知道大有可为答主
回答量:2132
采纳率:0%
帮助的人:1428万
展开全部
@echo off&setlocal enabledelayedexpansion

for /f "tokens=2 delims=:" %%i in (a.txt) do (
set "var=%%i"
set var=!var: =;!
for /f "delims=" %%a in ("%%i") do (
set "str=%%a"
set str=!str:;= !
echo !str:~1!
)
)>>op.txt
start op.txt
exit
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式