Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :Ini_cio
- (
- echo On Error Resume next
- echo Set objfso = createobject^("scripting.filesystemobject"^)
- echo Set arqtexto = objfso.opentextfile^("C:\teste.txt",2,true^)
- echo Set obj=CreateObject^("wscript.shell"^)
- echo If obj.appactivate^(wscript.arguments^(0^)^) = true then
- echo arqtexto.writeline "0"
- echo else
- echo arqtexto.writeline "1"
- echo End if
- )>"temp.vbs"
- :: "teste.txt" é o arquivo que voce quer comprovar se está aberto .
- start wscript temp.vbs teste.txt
- ping -n 2 127.0.0.1> nul 2>&1
- <"C:\teste.txt" set /p "_="
- if %_% equ 0 (
- taskkill /f /im "notepad.exe" >nul
- ) else (
- goto:Ini_cio
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement