When running a normal ConfigMgr package/program as a step in a task sequence, you cannot use variables on the command line. This happens because the execution of the program is actually managed by the execmgr, the clients normal execution manager, which does not know of any of the OSD environment. There are two ways to get around this limitation, use a script to reference the variables or change the step to install the software to a normal “Run Command Line” step, which can use variables and reference the original package.
So basically, a task sequence cannot call a normal ConfigMgr program and parse it Task Sequence variables, the OSD variables are not understood by the execmgr or they are not available:
In order to get around it you have to either use a script that runs as admin, referencing the TS object, or use the option to use a “Run Command Line” task that references the packagee source in the Task Sequence as the example below. In this example we feed two variables from the TS environment to the actual installer, and as you can see, its just a standard “Run Command Line” step:
Hope this saves some time for you guys!