Configuration Manager Software Distribution command line for Batch/CMD files

I am trying to use a CMD/Batch file with Configuration Manager 12 Software Updates to copy two files to a specific application folder on client machines.  I have
been unable to get the script to work with Software Distribution.  When I run the files manually they work. 

I am using the command line:  CMD /c file.cmd.  I have tried various changes within the file as well.  One being COPY /Y "%~dps0*.*"
"C:\Program Files\Application"  and xcopy /RY "\\server\software\application\*.ocx" "C:\Program Files\application". 

The source file location is on our software deployment share for the site server so there is no rights issue for where the files reside.  I tried running software distribution with a drive letter thinking that the unc path is an issue.  I am running always with administrative rights.  I have used vb script in the past, but would like to know the proper command lines to send out Batch and cmd files in Software Distribution.

Thanks,

Brit


May 16th, 2013 9:03pm

I have in a script:

@echo off
msiexec /i "msi installer\isys91.msi" /qn Reboot=ReallySuppress
echo d | xcopy /y %~dp0ISYSCat.xml "c:\Program Files\ISYS 9"
echo d | xcopy /y %~dp0ISYS9.KEY "c:\Program Files\ISYS 9"
echo d | xcopy /y %~dp0ISYS9.LIC "c:\Program Files\ISYS 9"
exit

And in the Software Library -> Application Management -> Applications, select the application's deployment type properties -> Programs, I have the Installation Program as simply isys32.cmd.  I am not using a cmd.exe /c isys32.cmd or anything like that to launch it, and it works fine for me.

Free Windows Admin Tool Kit Click here and download it now
May 16th, 2013 9:54pm

This thread might also be useful.

http://social.technet.microsoft.com/Forums/en-US/configmgrswdist/thread/fe7c6227-b883-4654-9e9d-74d72dfb1a27

May 17th, 2013 10:07am

I would like to use %~dpo.  I have a cmd file that I changed to copy two .ocx files.  When I run it manually it copies these two .ocx files.  It is called copy.cmd

The CMD looks like this:

COPY /Y "%~dp0*.ocx "C:\Program Files\application"
COPY /Y "%~dp0*.ocx " "C:\Program Files\application"

What I am not understanding is what to place in the command line in the Software Distribution program command line.  Would it be run Copy.cmd?

Can this type of file be run with UNC and to machines logged off?  

Thanks,

Brit 

Free Windows Admin Tool Kit Click here and download it now
May 17th, 2013 2:27pm

Hi,

I would create a package/program for this. Include your two .ocx files in the package. All the .cmd file would then have to do is move these .ocx files from the ccmcache location to the final destination. Much easier (in my opinion), because you remove the need for UNC.

May 17th, 2013 2:36pm

So what you are suggesting if I am understanding:

Create a Software Distribution package and program. Download content to Cache on the local machines and then copy over to the destination?

What I am not understanding is when I create the package and Program I am not sure what to use for the command line in the program to call the .cmd file.  Even if the two .ocx files are contained along with the .cmd file in the package and pulled down into local cache the cmd file needs to be called to run.  This is what I have been doing, but am not able to get the cmd file to run.

I may be completely confused.  :  )

Free Windows Admin Tool Kit Click here and download it now
May 17th, 2013 4:47pm

Brit,

If your package source folder contains the following files:

 - install_mystuff.cm
 - MyOcx1.dll
 - MyOcx2.dll

  

Your program should be set to "install_mystuff.cmd" and the batch file should contain the following lines:

XCOPY /Y "%~dp0MyOcx2.dll" "%ProgramFiles%\My Application Folder\"
XCOPY /Y "%~dp0MyOcx2.dll" "%ProgramFiles%\My Application Folder\" 

Note that with xcopy the target folder needs to include the trailing slash for it to know that the target is a folder and not a file.

Always copy the contents locally.  When ConfigMgr runs the program as Administrator, it executes as the local SYSTEM account which typically won't have access to any remote file shares. 

I hope that helps,

 

May 17th, 2013 4:59pm

I tried this and it did not work.  I then tried:

COPY /Y "%~dps0*.*" "C:\Program Files\application\"
COPY /Y "%~dps0*.*" "C:\Program Files\application\"

When it is manually ran it works with the folder structure, but I found that I have a permissions issue on the application folder.  Manually running the script against this folder it fails with a permissions error.  I am an administrator on the machine running the application.

Deploying with Configuration Manager it also fails even deploying with administrative rights.  Is there a command I can place into the script to elevate permissions or change permissions?

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2013 5:47pm

Thanks for all of the posts on this.  I have tried many different combinations and the scripts only work manually.  The latest I have tried is to run attrib in the batch file for a permissions issue I am running into on the application folder.  Manually the script works, but a deployment with Software Distribution it does not work.  I run the command batchfile.bat or script.cmd in the command line.  I run with administrator rights and have tried with user logged on, with user logged off.  I am downloading the contents first to local cache. 

Thanks,

Brit

May 31st, 2013 4:27pm

...permissions issue on the application folder.

 

Is the Program set to install for system?  If so, it will run as the SYSTEM account, which should not have any issues access a program files folder.

 

 

Nash

Free Windows Admin Tool Kit Click here and download it now
May 31st, 2013 4:35pm

I am running as administrator.  I have checked the program and do not see a selection to install as system?
May 31st, 2013 4:50pm

I am running as administrator.  I have checked the program and do not see a selection to install as system?

If you've selected in the program options to run with administrative rights (on the Environment tab), the program will run as the local SYSTEM account when it is deployed.

Here's a good way to test if your script will work running as SYSTEM:

http://myitforum.com/cs2/blogs/jmarcum/archive/2010/08/25/150872.aspx

Free Windows Admin Tool Kit Click here and download it now
May 31st, 2013 6:45pm

Batch will not work unless it is present on the client.  I do not see a way to make this work.  All other deployments with vb script work well so I may stick with this method instead. 

Thanks,

Brit

June 4th, 2013 8:12pm

Batch will not work unless it is present on the client.  I do not see a way to make this work.  All other deployments with vb script work well so I may stick with this method instead. 

Thanks,

Brit


I think you're making a very good decision to go with VBScript over batch.
  • Marked as answer by Brit2008 Tuesday, June 04, 2013 8:18 PM
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2013 8:14pm

I found running an elevated .cmd (batch) file containing the following is easier than the PSTools option. A UAC prompt will pop up, if enabled and when the cmd prompt is exited, the service is deleted. I turn echo off always, that way if it fails, I kick myself and turn echo back on.

@echo off
sc create CmdAsSystem type= own type= interact binPath= "cmd /c start cmd /k (cd c:\ ^& color ec ^& title ***** SYSTEM *****)"
net start CmdAsSystem
sc delete CmdAsSystem


as Nash Pherson says,

<-- If this post was helpful, please click "Vote as Helpful".


June 26th, 2015 12:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics