I use below coding to open an application. The PClist has list of all IP address of the remote PCs that I want to execute the program and an dummy IP 0.0.0.0 at last to trigger the program execution at the master.
@echo off setlocal enableextensions enabledelayedexpansion st b="C:\Program Files\TeamViewer\TeamViewer.exe" For %%B in (%b%) do ( Set c=%%~dpB Set d=%%~nxB ) for /f "tokens=*" %%a in (C:\COST\PCList.txt) do ( IF %%a equ 0.0.0.0 ( cd %c% "%d%" ) ELSE ( ping %%a -n 1 -w 100 IF errorlevel 1 ( ECHO REMOTE %%a IS NOT REACHABLE ) else ( psexec \\%%a -i -d -s cmd /c cd %c% psexec \\%%a -i -d -s cmd /c "%d%" ) ) )
My problem is that when I run the above batch file the application opens and also an empty cmd console is open at background in the Master as well as slave PCs. It doesn't close until I close the launched application*(In this case Teamviewer)* or the directly the console window.
Is there any way to make the console window to close automatically?