Link to home
Start Free TrialLog in
Avatar of Chad Franks
Chad Franks

asked on

SCCM 2012 - Incorrect function on scripted install deployment

I am using SCCM 2012 to deploy some applications.  I am having issues with one of them not deploying.  I keep getting "installation failed"  " Incorrect Function".  Its a simple batch file that creates a folder in C:\program Files(x86) and copies files to it .  Thats it.   I have tried doing a straight up file copy, I have tried using psexec to run it with elevated credentials etc.. but nothing is working.  Please look below and let me know what I am doing wrong?  Makes no sense:

I have tried so far:

@echo on

CD /d %~dp0

%~dp0psexec.exe -u **\ -p *** -h -i cmd /c mkdir "%ProgramFiles(x86)%\UMAX\"

COPY /Y %~dp0Files\*.* "%ProgramFiles(x86)%\UMAX"
GOTO END

:End
   @Echo ON
   Exit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I'm guessing it's permissions and the unhelpful error from the bat file is because BAT files are not suited to silent deployment or SCCM in general. Please avoid them. Use PowerShell instead.

Why are you trying to manually write files to Program Files anyway? What application do you have that has no installer? It doesn't bode well.

Mike
Batch files work fine with SCCM...I use them all the time.

1. If you try these commands from an elevated command prompt at the console by hand, do they work?
2. Are you running the program under Admin mode in the program settings in SCCM?

SCCM will run your batch files from ccmcache on the C: drive of the client, so it will assume that is the working path, so I don't know that you need all the %~dp0s.
Hi Adam/Chad

Yes, I know BAT files work. I never said they don't - just that they are not suited. The trouble comes when they don't work. They don't trap errors, they can crash without sending any error code and they are very old technology.
You *could* put lots of error trapping in but it would take time which is better spent elsewhere.


Both VBS and Powershell have better error handling built-in to them. The other problem is that people get mixed up over paths and sticking %~dp0s because they don't understand path'ing in CM and because "that's the way they've always done it." It works in login scripts and from network shares but don't expect it to work from everywhere.

My point is simple: you will save a lot of grief switch to VBS or PowerShell now rather than later as CM is now very PowerShell aware.

File copy
A better file copy is already available here: http://blog.coretech.dk/mip/making-file-copy-easy/
You need to create a package and then add it to a Task-sequence.
Copyright and thanks go to Michael Petersen


I still don't like the idea of manually copying files to Program files either. If the vendor has left something out that you have to do post install tweaks then they are slacking and makes me wonder what else they have got wrong.

Mike
He's copying a file to a folder...I don't think PowerShell is necessary in this case.  We are of course assuming that he has Powershell loaded on all of the computers in his environment and that the ability to run such scripts is allowed, etc.  WSH and the command interpreter are pretty much universal to Windows since Windows XP (circa 2001).