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

ID: 35058638
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

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

Expert Comment

by:David Johnson, CD, MVP
ID: 35075777
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
ID: 35082615
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

815 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

8 Experts available now in Live!

Get 1:1 Help Now