Skip to content

SCCM Batch file Deployment on Win 7

Featured Replies

I am new to SCCM, and I'm having problems with a batch file running automatically from cache on a Windows 7 machine,

 

I created a package with two programs, both are set to deploy locally and run from cache, using a unc path and to run with admin rights and to deploy whether the users logged in or not.

 

I have set the main program to run the msi and transform file via a command line which runs and installs fine.

 

The problem is with the second linked program, its a batch file, with a simple xcopy command such as xcopy "%~dp0Redirect.txt "c:\program files\example"

 

It fails to execute automatically, although it runs ok manually from cache when I "run as administrator" and I understand the UAC comes into force since

I want to copy a file into the Program Files area, although I thought deploying/running the program with admin rights "elevates" the rights for the user from SCCM so a specific app can install, so I didn't this would be the reason why it fails to run, is there anything I'm missing?

If you install the required app and the config in the batch file using a task sequence you should be able to achieve what is desired. If the install runs cleanly from the batch file direct there is no scripting error, so try the TS and this should complete ok.

If running the batch file with the Windows Sysinternals tool doens't get you anywhere, can you post the code from your batch file? Maybe there's something off about the code...

  • Author

Thanks for your replies,

 

Myself and my colleagues are new to SCCM coming from a Novell "Zenworks environment". We have just recently migrated to an AD environment, and are starting to use the tools to go with it. All the programs we have packaged so far that include batch files fails to execute. Athough all of the MSI's deploy and run successfully as you'd expect, and the batch scripts are correct as they execute when you run them manually from cache.

 

The batch files we use and have problems with all have different complexity depending on the app and all execute manually successfully, but all i want to do with one program is to copy a file from the cache location into its software app folder within program files on a Window 7 32bit machines, its simply just a one line xcopy command such as

 

xcopy "%~dp0Redirect.txt "c:\program files\shaunsoft\CTX"

 

basically want to copy Redirect.txt. into the "c:\program files\shaunsoft\CTX" folder

 

I also tried running it from the command line "redirect.bat" to deploy directly from the DP but still no joy.

 

Eventually we are looking to purchase a MSI packager such as Admin Studio etc, but batch files are regularly used with SCCM, so it's strange why we are experiencing such an issue.

 

I'm clutching at straws, but Is there anything on the SCCM end needing configured differently, to help push them to execute, we bought in consultancy to configure the SCCM server etc and to package a few apps, although they were MSI only packages, and the consultant was unsure why the batch files were not executing either.

 

Is there anything standard that may have been mis-configured/disabled at the SCCM administration.

Try this in you batch file. Should work in any case.

 

pushd %~dp0

copy redirect.txt "c:\program files\shaunsoft\CTX" /y

popd

  • 1 month later...
  • Author

Hi,

 

Sorry for the delayed repsonse, trying the pushd in my batch file worked a treat,

 

Thanks guys for your responses.

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.