Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6521
  • Last Modified:

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

0
Chad Franks
Asked:
Chad Franks
  • 2
  • 2
1 Solution
 
David Johnson, CD, MVPOwnerCommented:
unless you change the permissions for c:\program files (x86) you will have problems since only TrustedInstaller has the necessary rights to this protected area. you could use the -s parameter to run as 'system' And System has the highest privileges on any computer
0
 
Mike TLeading EngineerCommented:
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
0
 
Adam LeinssCommented:
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.
0
 
Mike TLeading EngineerCommented:
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
0
 
Adam LeinssCommented:
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).
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now