Tag Archives: bat

Batch file running on command prompt but not in Microsoft window scheduler

Batch file running on command prompt but not in Microsoft window scheduler

Microsoft Scheduler not run the Scheduled task .bat file but working fine manually run.

I am created a job for rman backup scheduled and created bat file to execute it in Microsoft windows Scheduler. On running the .bat file manually it’s running successfully.
But when I scheduled it with windows scheduler its not running actually finished in 1 seconds as shown in windows scheduler history.

Followings all the steps I performed to solve my problem. I would guess that maybe some of these face same problem.


1) Open the Task Scheduler of Microsoft Windows.
2) On General Tab, make sure the task is set to “configure for Windows Vista or Windows 2008” on the first page of the task properties.
3) On Action Tab, Open the Task Properties by click on “edit” Button at bottom, need to set the “start in” field with the folder location where the batch file located.
In the “Edit Action” Window there is a field for “start in (optional)” that you set to the path to the batch file.
D:\scripts\rman.bat is the my file for rman backup , then set “Start in (optional)” with D:\scripts value.
4) Make sure that the task is running as an account that has explicit “Full access” permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn’t seem to work for me.
5) Make sure that the account running the task is a member of the local “administrators” group for this machine.
5) Make sure that the task is set to “run whether logged on or not”
6) The Task should run successfully with expected output when you right-click on the task and select “run”
If it does that then it will run successfully when you are logged off.


Script for List the Drives with Size in Windows as Batch script

Script for list all the drives with size information in windows platform

Use steps as follows:

1. Save the below script as batch file with any name like diskinfo.bat

2. Go to the location of script placed:
 Cd D:\scripts

3. Open the command prompt windows and execute it with following command:
D:\scripts> diskinfo.bat localhost
4.  Output as follows:

Drive: C:
Total space: 266 GB
Free space : 221 GBDrive: D:
Total space: 482 GB
Free space : 482 GB

Script as follows:

IF "%~1"=="" goto help

@FOR /F "skip=1 tokens=1" %%x IN ('"WMIC /node:"%1" LOGICALDISK GET Name " ') DO (

@FOR /F "tokens=1-3" %%n IN ('"WMIC /node:"%1" LOGICALDISK GET Name,Size,FreeSpace | find /i "%%x""') DO ( @SET FreeBytes=%%n & @SET TotalBytes=%%p

SET TotalSpace=!TotalBytes:~0,-9!
SET FreeSpace=!FreeBytes:~0,-10!

SET /A TotalUsed=!TotalSpace! - !FreeSpace!

REM IF !TotalSpace! LSS 0 goto error

@echo Drive: %%x
@ECHO ===========================
@ECHO Total space: !TotalSpace! GB
@ECHO Free space : !FreeSpace! GB

REM @SET TotalSpace=
REM @SET FreeSpace=
REM @SET TotalUsed=
REM goto end
goto end
echo *** Invalid server or drive specified ***
goto help

echo diskfree.cmd
echo Queries remote server for free disk space.
echo Specify a MACHINENAME and a drive letter to be queried
echo Example:   diskfree.cmd MACHINENAME c:
goto end