a program that calls a .cmd file will not run

I have created a package that calls a .cmd file.   This .cmd file has 2 lines of code.

Powershell.exe -executionpolicy bypass -File  "%~dp0EndProcess.ps1"
copy "%~dp0Paragon\*.*" "C:\Program Files\Paragon1211" /Y

for the PowerShell line I have tried setting the execution policy to bypass & unrestricted and it never runs.  What happens is the source files are copied down to the c:\windows\cache folder and then the package never runs.  In fact it times out.

My package properties are to run "whether or not a user is logged on".  So why does not fail to run?  How else do you write the PowerShell line of code?  

I do not find the package ID in the CAS or Execmgr logs.  

April 22nd, 2015 12:17pm

All programs when run will have an entry in execmgr.log on the client.
Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 12:37pm

SCCM runs the package as the local system account, so make the local system account has rights to the file source. The Authenticated Users group should get you there. -Tony
April 22nd, 2015 12:45pm

the exemgr had rolled over.  I have this log entry.


As for the Local System account.  The package files are copied down to C:\Windows\CCM\Cache\ so it has full rights to that location.   

Notifying endpoint 'execmgr' of __InstanceModificationEvent settings change on object SMS_MaintenanceTaskRequests.TaskID="{685C58AE-6949-4163-993E-4AF443D961BD}" for user 'S-1-5-18'. CCMEXEC 4/22/2015 8:30:34 AM 10196 (0x27D4)
*** System is now free to go to sleep CcmExec 4/22/2015 8:30:34 AM 6100 (0x17D4)
*** Keep the system awake CcmExec 4/22/2015 8:30:34 AM 1416 (0x0588)
Notifying endpoint 'execmgr' of __InstanceModificationEvent settings change on object SMS_MaintenanceTaskRequests.TaskID="{685C58AE-6949-4163-993E-4AF443D961BD}" for user 'S-1-5-18'. CCMEXEC 4/22/2015 8:30:34 AM 6876 (0x1ADC)
Notifying endpoint 'execmgr' of __InstanceDeletionEvent settings change on object CCM_SoftwareDistribution.ADV_AdvertisementID="MH120100",PKG_PackageID="MH100173",PRG_ProgramID="CopyNewParagonFiles" for user 'S-1-5-18'. CCMEXEC 4/22/2015 8:47:40 AM 11816 (0x2E28)
Notifying endpoint 'execmgr' of __InstanceCreationEvent settings change on object CCM_SoftwareDistribution.ADV_AdvertisementID="MH120101",PKG_PackageID="MH100173",PRG_ProgramID="CopyNewParagonFiles" for user 'S-1-5-18'. CCMEXEC 4/22/2015 8:55:39 AM 10616 (0x2978)
Notifying endpoint 'execmgr' of __InstanceModificationEvent settings change on object SMS_MaintenanceTaskRequests.TaskID="{D046C497-64F3-4946-9AAC-6F1C7914C81F}" for user 'S-1-5-18'. CCMEXEC 4/22/2015 8:58:06 AM 10616 (0x2978)
Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 12:53pm

As for the Local System account.  The package files are copied down to C:\Windows\CCM\Cache\ so it has full rights to that location.  

When the package executes, (e.g., the power-shell command) this runs as local system, thus local system needs rights to the source [C:\Program Files\Paragon1211] to execute the copy.

-Tony



April 22nd, 2015 12:59pm

Can you provide a little more details - which of the two command is failing? the powershell.exe or copy program?

If the first one, are you sure that the powershell script is okey? If you try to replace it with dummy one (let say with simple one-line get-childitem C:\ ) does it pass?

Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 1:17pm

I know both commands works since I can run it manually and it all works.   And I checked the permissions on the c:\program files\paragon1211 folder and SYSTEM has full rights.   
April 22nd, 2015 1:28pm

Just try adding the Authenticated Users group to the c:\program files\paragon1211 folder, that is what I had to do to allow my batch scripts to work. -Tony
Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 2:05pm

That's not helpful. Without knowing why it failed, we can't tell you anything other than guessing at possible causes.
April 22nd, 2015 2:15pm

Really weird,

I tried this as a package just now.

Created something very similar a .cmd with a very similar command line.

Deployed it to a Windows 8.1 vm, forced a machine policy via right click tools.

All I got in the log was this.

Nothing else, did a couple more policy updates. No change.

I tried the same again but having the cmd file have the full path to the powershell.exe expecting this to work. Nothing changed.

(This does work as a custom action within an MSI I do it all the time and deploys fine in SCCM without changing the execution policy)

If I create a new package\program and point the program straight to the .ps1 file with no batch file I get an error.

If I then do the same thing again but change the execution policy on the client via the client settings and set it to bypass it works fine when pointing straight to the .ps1 file.

I'll check again though later, I can't see any reason why calling a ps1 from a bat or cmd wouldn't work.


Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 3:10pm

Was bugging me had to recheck. I must of made a typo or something before.

Created a new package fresh,

contents of bat / cmd file

C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -executionpolicy bypass -File  "%~dp0POSH.ps1"

Works fine without changing the execution policy in client settings.

April 22nd, 2015 3:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics