[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

Calling a program from a bat script

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

Thanks,

Lyon
0
LyonJay
Asked:
LyonJay
1 Solution
 
RussPitcherCommented:
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
0
 
dooetCommented:
add ";C:\Program Files\Windows Resource Kits\Tools" to the path (without quotes)
in System Proerties >> environment variables >> system variables
0
 
David Johnson, CD, MVPOwnerCommented:
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
0
 
Steve KnightIT ConsultancyCommented:
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
cls
echo %date% %time% Running delprof
pushd
 "C:\Program Files\Windows Resource Kits\Tools"
delprof.exe /Q /I /D:30
rem some other resource kit commands here
popd
echo %date% %time% Finished running delprof
pause


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.

Steve
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now