如何在 bat 文件中几秒钟后删除 .hta 文件
How Do I delete .hta file after some seconds in bat files
我有这个代码:
@echo off
@title Login
echo ^<htm^> >> "start.hta"
echo ^<head^> >> "start.hta"
echo ^<link rel="stylesheet" link="style.css"^> >> "start.hta"
echo ^</head^> >> "start.hta"
echo ^<body^> >> "start.hta"
echo ^<p^>Hello!^</p^> >> "start.hta"
echo ^</body^> >> "start.hta"
echo ^</html^> >> "start.hta"
start.hta
但是,我想在 10 秒结束时删除“start.hta”并关闭 window。
我该怎么做?
通过合并一些powershell
获取进程id,休眠10秒并通过进程id杀死。
@echo off
@title Login
echo ^<htm^> > "start.hta"
echo ^<head^> >> "start.hta"
echo ^<link rel="stylesheet" link="style.css"^> >> "start.hta"
echo ^</head^> >> "start.hta"
echo ^<body^> >> "start.hta"
echo ^<p^>Hello!^</p^> >> "start.hta"
echo ^</body^> >> "start.hta"
echo ^</html^> >> "start.hta"
for /f %%i in ('powershell "(Start-Process start.hta -passthru).ID"') do (
timeout /t 10
taskkill /F /PID %%i
del "start.hta"
)
我有这个代码:
@echo off
@title Login
echo ^<htm^> >> "start.hta"
echo ^<head^> >> "start.hta"
echo ^<link rel="stylesheet" link="style.css"^> >> "start.hta"
echo ^</head^> >> "start.hta"
echo ^<body^> >> "start.hta"
echo ^<p^>Hello!^</p^> >> "start.hta"
echo ^</body^> >> "start.hta"
echo ^</html^> >> "start.hta"
start.hta
但是,我想在 10 秒结束时删除“start.hta”并关闭 window。 我该怎么做?
通过合并一些powershell
获取进程id,休眠10秒并通过进程id杀死。
@echo off
@title Login
echo ^<htm^> > "start.hta"
echo ^<head^> >> "start.hta"
echo ^<link rel="stylesheet" link="style.css"^> >> "start.hta"
echo ^</head^> >> "start.hta"
echo ^<body^> >> "start.hta"
echo ^<p^>Hello!^</p^> >> "start.hta"
echo ^</body^> >> "start.hta"
echo ^</html^> >> "start.hta"
for /f %%i in ('powershell "(Start-Process start.hta -passthru).ID"') do (
timeout /t 10
taskkill /F /PID %%i
del "start.hta"
)