/build/static/layout/Breadcrumb_cap_w.png

Runing .cmd from SCCM 2007 ("%~dp0)

I am trying run a batch file to my Windows 7 (x64) client with SCCM 2007. Most of the apps (which are all msi installs) apart from 3 which I am calling using .cmd files.

Looking at the deploy logs I can see that the database returns the correct package_id and the correct .cmdfile is being run and it even returns a status of successful.

Below is an example of one of the .cmd files I am trying to run. The %~dp0 means from the current location, so I wouldn't have thought it would be a problem with UNC paths. The files copies successfully to the path but the installert doesn't run. Here the script template:

copy "%~dp0*.*" "c:\users\default\appdata\local\temp\"
start c:\users\default\appdata\local\temp\setup.exe /s /SMS


If I run the .cmd file manually from the client, it works -but not from my "Run Command Line" step i the Task Sequence.

Could somebody help me with this script?

Best regards,
Kenny

0 Comments   [ + ] Show comments

Answers (8)

Posted by: randboten 11 years ago
White Belt
0

I know this is an old question, but has anyone tried the cmd /c copy? I have several packages in our environment, which require copy (icon.dll's, etc), and I have had great success using this command. May also want to run as a second program to get the program to actually run. Maybe build a package with the program run as a dependent variable set task variable of the copy program and put them in the task sequence (3 steps reuired: one defining each variable, and one starting the set task sequence variable sequence. Hope this makes sense/helps someone.

Posted by: michaelnowell 13 years ago
Second Degree Blue Belt
0
Try setting the Program's Environment to 'Requires drive letter'. It won't work if it's a UNC.
Posted by: KennyBrez 13 years ago
Senior Yellow Belt
0
Hi Michael and thanks for the quick response!

Could you please give me an example of setting Program's Environment to 'Requires drive letter?

The command successfully copies the setup.exe, setup.iss etc. to c:\users\default\appdata\local\temp\ at the clients, but someting is missing in the start command. SCCM gives me a successfully error code, but I think the installerer just can't find the right working directory.

Best regards,
Kenny
Posted by: mikkojarvinen 13 years ago
Senior Yellow Belt
0
[font="courier new"][font="times new roman"]I don't quite understand that copying part. Task Sequence copies data to the client. Anyway I would try adding the /wait option to the start command:

start "" /wait [font="courier new"]setup.exe /s /SMS
[font="times new roman"]
--
Mikko Järvinen
Posted by: KennyBrez 13 years ago
Senior Yellow Belt
0
Thanks Mikko,

OK, tried:

copy "%~dp0*.*" "c:\users\default\appdata\local\temp\"
start "" /wait c:\users\default\appdata\local\temp\setup.exe /s /SMS


It starts, but just aborts with no install :-(

Best regards,
Kenny
Posted by: pjgeutjens 13 years ago
Red Belt
0
you could try your script like this:

pushd %~dp0
copy /Y *.* "c:\users\default\appdata\local\temp\"
start "" /wait c:\users\default\appdata\local\temp\setup.exe /s /SMS

I added the /Y just to avoid annoying prompts

Another option might be to let SCCM handle the local caching of the files by setting the option in your advertisement (distibution points tab - Download content and run locally). This assumes that the setup.exe only has to anywhere on the local machine, and not specifically in that exact folder, and just running the setup in the cmd without the extra filecopy like

pushd %~dp0
start "" /wait setup.exe /s /SMS

Hope this helps,

PJ
Posted by: anonymous_9363 13 years ago
Red Belt
0
If I run the .cmd file manually from the client, it worksRemember that SMS/SCCM installs using the local System account. Does it run when you run it as the local System account? Use the old 'AT /INTERACTIVE' dodge to get a command prompt as local System, then try. I'd wager it will fail.

In that case, I'd investigate whether the EXE extracts and executes an MSI. If it does, great - create a response transform and use the combination to install. If not, re-package it.
Posted by: admaai 13 years ago
Orange Senior Belt
0
"Run Command Line" step i the Task Sequence ORIGINAL: KennyBrez

Maybe your command line does not work in task sequence, one possibility is that your package requires a user profile. In SCCM R2 you can set your commandline to run as a user. There are usually 1 or 2 domain user accounts configured in AD for TS, try running it as those users, or use a variable to run it as localadmin.
Btw this post belongs to SCCM section.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ