none
startup script not running through gpo

    Question

  • Here is the vbs script:

    on error resume next
    dim oUIResManager
    dim oCache
    dim oCacheElement
    dim oCacheElements
    set oUIResManager = createobject("UIResource.UIResourceMgr")
    if oUIResManager is nothing then
    wscript.quit
    end if
    set oCache=oUIResManager.GetCacheInfo()
    if oCache is nothing then
      set oUIResManager=nothing
      wscript.quit
    end if
    set oCacheElements=oCache.GetCacheElements
    for each oCacheElement in oCacheElements
      oCache.DeleteCacheElement(oCacheElement.CacheElementID)
    next
    set oCacheElements=nothing
    set oUIResManager=nothing
    set oCache=nothing
    wscript.quit

    _______________

    I can manually run successfully. But it wont run when I put it into the policy at computer configuration\policies\administrative templates\system\script: enable run startup scripts asynchronously. I manually copied the vbs script to \\domain controller server\c$\windows\SYSVOL\domain\Policies\policy id\Machine\Scripts\Startup.

    The above script is intended to clear ccmcache on all the client workstations.

    Any advice as how to troubleshoot this issue? I could not anything in event viewer.

    Thank you very much!

    Wednesday, December 21, 2016 10:00 PM

All replies

  • Does the script even start? Add some debugging to it (write output to eventvwr at the startup) to see if it's starting correctly. Although, I'm assuming that the ccmexec -service (ConfigMgr Agent), which you're calling hasn't started at the time your script is running.

    More proper way of cleaning the ConfigMgr cache would be for example this: http://rzander.azurewebsites.net/sccm-config-item-to-cleanup-ccmcache/ where you utilize compliance settings through ConfigMgr itself.

    Consider this, if the client computer has downloaded for example updates to it's cache and are waiting for deployment to start and you clean the cache on every startup the client will re-download the stuff to it's cache -> you've got clean cache -> download content -> clean cache scenario at your hands.

    This post would be properly better in the ConfigMgr forums.



    • Edited by Narcoticoo Thursday, December 22, 2016 4:24 AM
    Thursday, December 22, 2016 4:23 AM
  • > Here is the vbs script:
    > I can manually run successfully. But it wont run when I put it into the policy at computer configuration\policies\administrative templates\system\script: enable run startup scripts asynchronously. I manually copied the vbs script to \\domain controller server\c$\windows\SYSVOL\domain\Policies\policy id\Machine\Scripts\Startup.
     
    What exactly did you enter in the script parameters in your GPO?
     
    Thursday, December 22, 2016 8:59 AM
  • BTW, we could dramatically shorten this script :-)
     
    set oUIResManager = createobject("UIResource.UIResourceMgr")
    set oCache=oUIResManager.GetCacheInfo()
    set oCacheElements=oCache.GetCacheElements
    for each oCacheElement in oCacheElements
       oCache.DeleteCacheElement(oCacheElement.CacheElementID)
    next
     
    If we remove "on error resume next", it will terminate upon failure to create any of these objects. So we don't need to check for "is nothing / wscript quit". And since we do not use "option explicit", there's no need to dim any variables.
     
     
    Thursday, December 22, 2016 9:03 AM
  • thank you very much!
    Thursday, December 22, 2016 5:23 PM
  • There is nothing that you need to put in gpo other than enabling the gpo setting.
    Thursday, December 22, 2016 5:25 PM
  • thank you. You did bring me the good point.  How and where shall I put this ps script? Would you mind giving me some more information on this?
    Thursday, December 22, 2016 5:27 PM
  • Hi,

    You could create a folder the put the script to the folder. Then Configuring related permission for computers, which will run the script.

    For configuring group policy, you need type the UNC path for the script in Startup script in GPO.

    Best Regards,

    Jay


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, December 23, 2016 7:34 AM
    Moderator
  • > There is nothing that you need to put in gpo other than enabling the gpo setting.
     
    Nah - at least we have a script name and script parameter field... :)
     
    Friday, December 23, 2016 3:37 PM
  • Hi,

    Are there any updates?

    If the reply above has resolved your problem, please mark it as answer as it would be helpful to anyone who encounters the similar issue.

    Thank You.

    Best Regards,

    Jay


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, December 30, 2016 1:12 AM
    Moderator