Using SCCM to push out a batch file to run

I have created a batch file that I need to run on Pc's/Servers with the SCCM client, and I was wondering if there was any special way the "packages" needed to be configured, or it there were any special commands I need to type in the command line for the new "program".

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your program line will need to be

cmd.exe /c "c:\mybatchfile.bat"


cmd.exe /c "\\servername\servershare\mybatchfile.bat"

You can also do it as a Task Sequence, Advertised to machines with a one step Task Sequence "Run a command line"

Again - the command line will be as above
DonaldWilliamsAuthor Commented:
Oh, so I DON'T copy the batch file to the distribution servers? Just make a folder on a server share, dump the batch file in that, and create a "program" that just runs the batch file from that share?
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

DonaldWilliamsAuthor Commented:
Also, what do I do about "source files", say that there are none? How about distributing the package to the dist servers; do I have to do that?

I just need to know the correct steps, never did a batch file before with SCCM.
I do this all the time.  Assuming you already have your .CMD or .BAT file copied to your share.....

1) Create your collection
2) Create the package
   - Set the Source Directory to where your .CMD is located
3)Create the Distribution Point
4) Create a new Program
   - On the Command Line, browse to your .CMD file
   - Run it Hidden
   - On the Environment tab, verify it 'Runs with administrative rights'
   - On the Advanced tab, 'Suppress program notifications'
5) Create your advertisement

Within the .CMD file, I usually put %~dp0 right before the MSI or setup.exe.... this basically expands the correct path to your MSI or setup.exe.

Hope this helps.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Like all things there are several ways you can do this sort of thing....

Method 1.
Your program line will need to be

   cmd.exe /c "c:\mybatchfile.bat"

This is where you WOULD create a distribution point, the batch file is distributed to your distribution servers and the file is run from the distribution server.  The only problem is that the batch files directory location would vary depending on which distribution server it is run from.  (This is "windowsex" comment about using %~dp0 in the batch file to resolve the current working directory.

or Method 2
Your program line will need to be

   cmd.exe /c "\\servername\servershare\mybatchfile.bat"

In this case you store your batch file centrally on your network and just get the command line to run that batch file.  As batch files are usually pretty small the overhead on network bandwidth is pretty negligible but bear it in mind.

There are several question very similar to this in EE - do an Answer search for "How do I run a batch file in SCCM"

DonaldWilliamsAuthor Commented:
got it, thanks!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.