Speaking of code, this might interest you if you use or need something like CMDOW:
Code: Select all
@echo off
setlocal enabledelayedexpansion
rem set _NO_DEBUG_HEAP=1
set vYr=%date:~10,4%
set vMon=%date:~4,2%
set vDay=%date:~7,2%
set vHr=%time:~0,2%
set vMn=%time:~3,2%
set vSec=%time:~6,2%%time:~9,2%
set vFN=%vYr%%vMon%%vDay%%vHr%%vMn%%vSec%
rem @echo Checking to see if IDiary is already started
cd /d "%dCMDOW%"
if exist IDD.txt del /q IDD.txt
for /f "tokens=1-8,*" %%a in ('cmdow /f /b') do (
set hndl=%%a
set ttl=%%i
if "!hndl:~0,2!"=="0x" if "%%b"=="1" if "%%h"=="iDD" (
if "!ttl:~0,11!"=="iDailyDiary" (
@echo %%a %%b %%c %%d %%e %%f %%g %%h %%i>>IDD.txt
)
if "!ttl:~0,5!"=="Diary" (
@echo %%a %%b %%c %%d %%e %%f %%g %%h %%i>>IDD.txt
)
)
)
if exist IDD.txt (
for /f "tokens=1-8,*" %%a in (IDD.txt) do (
start cmdow.exe %%a /ACT /RES
)
)else (
if exist "E:\SyncEXP\Individual\SyncEXP.exe" (
@echo syncing diaries before start.
rem start /wait /d"E:\My Apps\Dependency Walker\" depends.exe /cpb /ot:"logs\SyncExpIDD_%vFN%.log" "E:\SyncEXP\Individual\SyncEXP.exe" -Diary
start /wait /d"E:\SyncEXP\Individual\" SyncEXP.exe -Diary
)
if exist "%PROGRAMFILES%\My Apps\iDailyDiary\iDD.exe" (
start /b /d"%PROGRAMFILES%\My Apps\iDailyDiary" iDD.exe
)
)
rem pause
endlocal
exit /b 0
exit
In this example CMDOW is used to check for the existence of IDailyDiary windows (an application I cannot live without) EnableDelayedExpansion is envoked so that the variables "hndl" and "ttl" can be checked in the IF statement. If IDailyDiary is already running, CMDOW is used to activate the correct windows. If not, the application is started after running a synchronizing application (that keeps my home and work diaries synchronized).