In: Computer Science
Create 2 more batch files called devTracker.bat and
showTracker.bat as follows:
devTracker.bat
a. This batch logs an entry into a log file called
C:\myTemp\devTracker.log
b. The entry in the log file should indicate the date and time of
the VS launch as well as a message indicating
that you started Visual Studio. Please log all of this information
on 1 line in the devTracker.log file
c. After making this log entry, devTracker.bat should run
myStart.bat for you
showTracker.bat
d. Create another batch file called showTracker.bat that displays
the contents of the devTracker.log
file in the command prompt window.
Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks
Remember to make folder : C:\myTemp
Code:
devTracker.bat
:search
@ECHO off
tasklist | find "dev" >nul
IF %ERRORLEVEL% == 0 ( GOTO found)
timeout /t 1 >nul 2>&1
GOTO search
:found
echo You Started Visual Studio = %time% %date%>>
"C:\myTemp\devTracker.log"
showTracker.bat
showTracker.bat
SET filename="C:\myTemp\devTracker.log"
type %filename%
Code Screenshot:
Explanation:
:search
@ECHO off -->suppressing output
tasklist | find "dev" >nul --> checking for task whether dev
is running or not. suppressing all output to nul
IF %ERRORLEVEL% == 0 ( GOTO found) --> while checking tasks if
there is no error then go to found
timeout /t 1 >nul 2>&1 --> if error then
wait for 1 sec and go to search. Here we used >nul 2>&1
to hide displaying error msg and timeout msg
GOTO search
:found
echo You Started Visual Studio = %time% %date%>>
"C:\myTemp\devTracker.log" --> if task is started log in
file
showTracker.bat --> open next batch
Output:
Batch is running but visual studio is not started.
Started Visual studio