Jump to content


Deploy applications with CMD script

Recommended Posts

Hi all,


First - Happy new year and that 2016 will be full of success!




I'm trying to create a simple script that install Java on a computer. The script is the following:


@echo java
@echo off
@set CWD=
SET CWD=%~dp0
echo Installing...
@start /wait %CWD%setup.exe /s
On the SCCM I have create one deployment type to execute this script (install.cmd). On the same folder where the script is, I have setup.exe (which is JAVA installer).
The detection method is on the java.exe... user experience is Install for system and on the content (deployment options), I'm downloading the content and running locally on the computer.
The deployment is set to be available so that the user can choose to install the program. I don't know how many times I tried this, but it fails when I press install on the software center nor application catalog and the logs don't show errors (appEnforce.log). Note that other deployments (using MSI) work very well. However scripts seems to need something else or more details. Does any has this kind of issue or know how to workaround this problem?
p.s. install Java is only an example. I need to change other programs that don't use MSI.
Thank you in advanced
Edited by ZeZe

Share this post

Link to post
Share on other sites

Using the application model to deploy scripts requires just a little more caution.


- Double check your detection method is correct and looking for the exe in the right location (prog file x86 / prog file etc)

- Double check the deployment type I actually "script" and not "Installer". I've made this mistake before, (https://technet.microsoft.com/gg675930.Fig_2_Each_application_can_have_multiple_types_of_deployment(en-us,MSDN.10).jpg)

- Does anything actually get downloaded into the "ccmcache" folder when you press install in Software Center?

- Whats the error code being displayed in Software Center? Press install, wait for the failure message and click "more information". (https://social.technet.microsoft.com/Forums/getfile/165322)


Also you could simplify your script if preferred, you could have just 4 lines:


@echo off
cd %~dp0 (this isn't required, but just makes sense to have if you will be manually installing on some machines)
setup.exe /s

Share this post

Link to post
Share on other sites



Thanks for the support!


1) Got it - I have cross check that one already!

2) I think I select script but I'm going to I'm going to cross check

3) ccmcache contains all files (setup.exe and install.cmd)

4) I'm going to check that again and let you know tomorrow :) but I think is related to the detection method (which fails since it fail to install? make sense?)... but I'm going to let you know tomorrow!


regarding the script:


For this type of script, can I simply use short commands (like start /wait setup.exe /s) ... I'll try that as well and let you know!


Thanks for the tips and I'll post the results :)

Share this post

Link to post
Share on other sites

You only need to use %~dp0 when you need to reference the full path to something.

For example a setup installer that also references an xml file (some Adobe apps are like this and you need to specify the full path to the xml file). In your example you can simply just call setup.exe /argument


To find out why the installer fails first try it outside of configmgr. Copy the source to a client. Download psexec and do psexec -I -s cmd.exe

This Will give a new cmd prompt

Typing whoami should show the local system account. This is the same account configmgr uses. Now run your command to install the software. Maybe add some logging. From here you can figure out why it fails. If you look on the configmgr technet forum you Will see some issues installing java using the local system account.

Share this post

Link to post
Share on other sites

Hi all,


So I found something... After all the changes I made in the script, those changes didn't had the impact on the client because the cache was always the same since the beginning. So basically even if I change a "coma" in the script file, while updating the content, didn't change nothing in the deployment... strange? Even when I rename the file name... the content on the cache folder didn't change a bit...


So I created a new application and took all the steps and did basically all you guys suggested. Now the error is on the script side...


Software Center: The software change returned error code 0x3(3).


Log AppEnforce.log:


Executing Command line: "C:\WINDOWS\ccmcache\7\inst.cmd" with user context AppEnforce 5-1-2016 09:38:06 4608 (0x1200)
Working directory C:\WINDOWS\ccmcache\7 AppEnforce 5-1-2016 09:38:06 4608 (0x1200)
Post install behavior is BasedOnExitCode AppEnforce 5-1-2016 09:38:06 4608 (0x1200)
Waiting for process 3596 to finish. Timeout = 120 minutes. AppEnforce 5-1-2016 09:38:06 4608 (0x1200)
Process 3596 terminated with exitcode: 3 AppEnforce 5-1-2016 09:38:23 4608 (0x1200)
Looking for exit code 3 in exit codes table... AppEnforce 5-1-2016 09:38:23 4608 (0x1200)
Unmatched exit code (3) is considered an execution failure. AppEnforce 5-1-2016 09:38:23 4608 (0x1200)
CD %~dp0
start /wait setup.exe /s
So... Error 3 means that the system cannot find the path specified... hmmm... I have try the script very simple (just 3 lines... ) and now I added the CD %~dp0... but it doesn't work... any ideas?
Thank you!!!

Share this post

Link to post
Share on other sites

Ok, good news...


The problem might be definitely on the Java installer! I tried the same script but with Firefox and it worked like a charme! No issues, no nothing!


I made it as simple as I could... The Java continues to give me error code 3... So Java installation with the switch /s it doesn't work... I bet if I do the same as a package it will work with no issues at all!

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...