RobD Posted October 12, 2016 Posted October 12, 2016 Hi, Need some help with copying files to C:\Program Files (x86)\Desktop\ with SCCM but before I do that I need to kill a process. Soooo I created a batch file: REM Check if a file exists? If not then install the new version, if it does then exit. if exist "c:\program files (x86)\Desktop\New_Version.flag" goto :EXIT ELSE goto :RUN :RUN taskkill /im Desktop.exe echo DesktopInfo.exe was killed xcopy /s \\Domain.net\sccm$\Source\Desktop_R3\*.* "C:\Program Files (x86)\Desktop\" /Y start "" "C:\Program Files (x86)\Desktop\Desktop.exe" end :EXIT end I then created a package and pushed it out but it fails, I was about to start going through the logs but I thought I'd ask here if I was actually doing this correctly as I'm totally new to SCCM. Any help would be awesome. Thanks
altecsole Posted October 12, 2016 Posted October 12, 2016 You should really test if this works under the System account, as that s the one that SCCM uses. I do this in the following way: Get a copy of PSExec from Microsoft Sysinternals (https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) Copy PSExec to the local machine Run a cmd prompt and CD to the location of psexec Use PSExec to run cmd as System psexec -si cmd.exe Confirm your using System using the command whoami Run your batch file to test for any errors cmd.exe /c c:\mybatchfile.bat Good luck!
RobD Posted October 12, 2016 Author Posted October 12, 2016 Thanks altecsole, was really useful. Yes it seems to be working as it should, is there anything I should do to run it on the package??
altecsole Posted October 12, 2016 Posted October 12, 2016 I find that creating a Package of source files (no program option) and then copying it locally can often work better than creating a Package to install. Once you've created your package of source files (and distributed it), add a Run Command Line option to your Task Sequence to xcopy the files locally - I copy them to the temp folder within Windows using the command line:xcopy ".\*.*" "C:\Windows\Temp" /D /E /C /I /Q /H /R /Y /S and add your package of source files. This will copy the source files folder to the local machine. You can then add an entry to the Task Sequence to run the batch file. Add another Run Command Line step to your Task Sequence and set the command to run your batch file (which you copied over with the source files). The command would be: cmd.exe /c C:\windows\temp\yoursourcefolder\yourbatch.bat Make sure you set the Start In option to the correct location - c:\Windows\temp\yoursourcefolder I hope that helps. Don't forget to keep an eye on the SMSTS.log using CMTrace.exe to see if you have any errors!
DavR Posted October 12, 2016 Posted October 12, 2016 Just a thought, but does your taskkill command need to be C:\Windows\System32\Taskkill.exe? I've found SCCM packages do mess around with your paths a bit, causing your script to behave differently as a package than running manually.
benbanks1 Posted November 25, 2016 Posted November 25, 2016 Hello, Totally random question but wanted to add to this thread rather than start a new one and not get a response . I'm wondering if anyone receives the following error when deploying an SCCM Windows 8.1 build: 0x00002751. I've searched this web page and other resources and the error appears to have been unheard of. Regards, Ben
jdell Posted November 29, 2016 Posted November 29, 2016 Hello, Totally random question but wanted to add to this thread rather than start a new one and not get a response . I'm wondering if anyone receives the following error when deploying an SCCM Windows 8.1 build: 0x00002751. I've searched this web page and other resources and the error appears to have been unheard of. Regards, Ben Hi Ben, when you say you are getting this error can you be more specific. Are you deploying via the PXE environment or Via Software Center. When you say you are installing 8.1 is this from a ISO or a custom capture? Is this a newly built task sequence or an updated one? Which version of SCCM are you running - (version number would be best.) If you are using PXE which version of the WINPE environment are you using? If you can give as much information as possible I will try to help out.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now