Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Chenry
- Posts: 3
- Joined: 30 Dec 2013 02:24
#1
Post
by Chenry » 14 Jan 2014 22:52
dear all,
I'm confused by command 'echo'.
I want to create a batch file with a script:
::Create Boot.bat
echo @echo off >> D:\Boot\Boot.bat
echo ping 127.0.0.1 -n 1 >nul >> D:\Boot\Boot.bat
echo tasklist ^| find /i "gpupdate.exe" >> D:\Boot\Boot.bat
echo if %errorlevel%==0 taskkill /f /im gpupdate.exe >> D:\Boot\Boot.bat
I want to get a script as below:
@echo off
ping 127.0.0.1 -n 1 >nul
tasklist | find /i "gpupdate.exe"
if %errorlevel%==0 taskkill /f /im gpupdate.exe
How should I change the first script?
Thank you all in advance.
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#2
Post
by Ed Dyreen » 15 Jan 2014 02:14
Chenry wrote:dear all,
I'm confused by command 'echo'.
I want to create a batch file with a script:
::Create Boot.bat
echo @echo off >> D:\Boot\Boot.bat
echo ping 127.0.0.1 -n 1 >nul >> D:\Boot\Boot.bat
echo tasklist ^| find /i "gpupdate.exe" >> D:\Boot\Boot.bat
echo if %errorlevel%==0 taskkill /f /im gpupdate.exe >> D:\Boot\Boot.bat
I want to get a script as below:
@echo off
ping 127.0.0.1 -n 1 >nul
tasklist | find /i "gpupdate.exe"
if %errorlevel%==0 taskkill /f /im gpupdate.exe
How should I change the first script?
Thank you all in advance.
Assuming delayed expansion is disabled
Code: Select all
::Create Boot.bat
> D:\Boot\Boot.bat (
echo(@echo off
echo(ping 127.0.0.1 -n 1 ^>nul
echo(tasklist ^| find /i "gpupdate.exe"
echo(if %%errorlevel%%==0 taskkill /f /im gpupdate.exe
)