Calling a program from a bat script

Posted on 2011-03-07
Last Modified: 2012-05-11
Dear all,

I have a program under the following directory:

C:\Program Files\Windows Resource Kits\Tools\delprof.exe

Normally I have to navigate my command prompt to that folder to call the program.

Does anyone know how I can put this into a script?

I also have to put the following after the script delprof.exe /Q /I /D:30


Question by:LyonJay

Expert Comment

Comment Utility
If it's a batch file or a PowerShell script simply call it as if you were typing it:

"C:\Program Files\Windows Resource Kits\Tools\delprof.exe" /Q /I /D:30

Open in new window

Don't forget to enclose any paths with spaces in quotes

Expert Comment

Comment Utility
add ";C:\Program Files\Windows Resource Kits\Tools" to the path (without quotes)
in System Proerties >> environment variables >> system variables
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
or --- cmd.bat --->
set path = %path%;"c:\program files\windows resource kits\tools\";
delprof /q /i /d:30

use in between the --> and <-- in your batch file
LVL 43

Accepted Solution

Steve Knight earned 500 total points
Comment Utility
If you want to run multiple entries from a path in a batch script then use the cd or pushd commands to change  to that dir, i.e.

@echo off
echo %date% %time% Running delprof
 "C:\Program Files\Windows Resource Kits\Tools"
delprof.exe /Q /I /D:30
rem some other resource kit commands here
echo %date% %time% Finished running delprof

Save it as whatever.cmd (rather than .bat) and off you go.

Or if ou just want to run this one script just create a new shortcut on your desktop etc. with the full path in it.


Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now