如何在一段时间后删除我的.hta 文件? [已关闭]

问题描述 投票:0回答:1
@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

以上是我的代码。我想要一种计时器,我们只需在计时器结束后删除该文件即可。

html batch-file hta
1个回答
2
投票

通过合并一些

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"
)
© www.soinside.com 2019 - 2024. All rights reserved.