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".

Thanks,
DonaldWilliamsAsked:
Who is Participating?
 
windows7expertCommented:
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.

 
0
 
MarkieSCommented:
Your program line will need to be

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

or

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


cheers
MarkieS
0
 
MarkieSCommented:
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
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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?
0
 
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.
0
 
MarkieSCommented:
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"

cheers
MarkieS
0
 
DonaldWilliamsAuthor Commented:
got it, thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.