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

x
?
Solved

Using SCCM to push out a batch file to run

Posted on 2011-10-05
7
Medium Priority
?
16,347 Views
Last Modified: 2013-11-21
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,
0
Comment
Question by:DonaldWilliams
  • 3
  • 3
7 Comments
 
LVL 8

Expert Comment

by:MarkieS
ID: 36918039
Your program line will need to be

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

or

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


cheers
MarkieS
0
 
LVL 8

Expert Comment

by:MarkieS
ID: 36918052
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
 

Author Comment

by:DonaldWilliams
ID: 36918091
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:DonaldWilliams
ID: 36918469
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
 

Accepted Solution

by:
windows7expert earned 500 total points
ID: 36919579
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
 
LVL 8

Assisted Solution

by:MarkieS
MarkieS earned 500 total points
ID: 36922908
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
 

Author Closing Comment

by:DonaldWilliams
ID: 36923852
got it, thanks!!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Case Summary: In this Article we introduce the new method to configure the default user profile using Automated profile copy with sysprep rather than the old ways such as the manual copy of a configured profile to default user profile Old meth…
1. Boot PC and press F10, select storage options and change the compatibility from “AHCI” to “IDE”, save and exit 2. Boot PC and press F12 3. Upon PXE display of searching for DHCP server, press Pause break to obtain MAC address 3. Open Configu…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

834 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