If your scheduled batch job needs to know if a user is logged on, call UserOn.

UserOn.bat returns a uon environment valiable, with a Y or N value. You can then test this variable:

call UserOn
if "%uon%"

"Y" goto UsrIsOn

If a user is logged on, the Shell is running. UserON.bat first determines the Shell value by running Reg and then uses tlist from the Resource kit to see if it is running.

UserOn.bat contains:

@echo off
set uon=N
for /f "Tokens=*" %%i in ('reg -Quiet -ListValue "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell"') do call :shell "%%i"
endlocal&set uon=%uon%
goto end
set sv=%1
set sv=%sv:"REG_SZ =%
set sv=%sv:"=%
for /f "Tokens=2" %%i in ('tlist') do call :find "%%i"
goto end
if "%uon%""Y" goto end
if /i "%sv%"==%1 set uon=Y