Deploy a Scheduled Task via GPO with Environment Variables


  • I am trying to push a Scheduled Task to my Windows 7 clients that will empty the Chrome cache folder every night.  I use the following action run as the current user.

    cmd.exe /c rd /s /q "%localappdata%\Google\Chrome\User Data\Default\Cache"

    This works correctly when created directly on a workstation.  However, I ran into an issue trying to push using GPO preferences.

    The targeted computers instead get the following created...

    cmd.exe /c rd /s /q "C:\Windows\system32\config\systemprofile\AppData\Local\Google\Chrome\User Data\Default\Cache"

    Clearly the GPO import process resolved the environment variable instead of passing it.  I need the Task created with the environment variable intact so it can resolve for whatever user is currently logged on at the time it runs.

    As a work-around I created a .CMD script containing the desired command, but I figured I would ask if there was a cleaner way to do this.  Unless there is something I am missing, this seems like a bug, so I figured I would post it.

    Friday, October 23, 2015 8:52 PM