Question

I made a batch file with the following script:

@echo off
goto start

:start
"C:\Games\SV_Debug\Data\Win32\InvisibleM2.vbs"
goto check

:check
tasklist /FI "IMAGENAME eq Launcher2.exe" >swap | find /I /N "Launcher2.exe" >swap
if "%ERRORLEVEL%" == "0" (
    goto waitrecheck
) else "%ERRORLEVEL%" (
    goto start
)

:waitrecheck
ping 127.0.0.1 -n 3
goto check

This batch file is executed by a vbscript that make's this batch invisible. The batch file runs a vbscript that runs Launcher2.exe normal and not invisible.

But this batch above here can't check is Launcher2.exe is running. When it tries I get this error:

The process does not have access to the file because it's being used by another program.

How do I fix this?

Was it helpful?

Solution

tasklist /FI "IMAGENAME eq Launcher2.exe" >swap | find /I /N "Launcher2.exe" >swap

You can not send the output of two programs to the same file at the same time

tasklist /FI "IMAGENAME eq Launcher2.exe" | find /I /N "Launcher2.exe" >nul
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top