Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. :Ini_cio
  3. (
  4. echo On Error Resume next
  5. echo Set objfso = createobject^("scripting.filesystemobject"^)
  6. echo Set arqtexto = objfso.opentextfile^("C:\teste.txt",2,true^)   
  7. echo Set obj=CreateObject^("wscript.shell"^)
  8. echo If obj.appactivate^(wscript.arguments^(0^)^) = true then
  9. echo arqtexto.writeline "0"
  10. echo else
  11. echo arqtexto.writeline "1"
  12. echo End if
  13. )>"temp.vbs"
  14. :: "teste.txt" é o arquivo que voce quer comprovar se está aberto .
  15. start wscript temp.vbs teste.txt
  16. ping -n 2 127.0.0.1> nul 2>&1
  17. <"C:\teste.txt" set /p "_="
  18. if %_% equ 0 (
  19. taskkill /f /im "notepad.exe" >nul
  20. ) else (
  21. goto:Ini_cio
  22. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement