none
Script to delete content in c:\windows\temp

    Question

  • Hi, I want to remove content of c:\windows\temp on all of computers in my domain.

    I'm using script like that

    "rmdir /S /Q c:\windows\Temp"

    and it's working on my local computer, when I run it

    I've pasted the bat file to DC Sysvol lacation, and I've configured shutdown script in GPO Computer Configuration.

    When i reboot my computer it doesn't clean Temp location.

    Could you give me a hand?

    Thanks

    Ernest

    Thursday, January 12, 2017 6:47 AM

All replies

  • Hi Ernest.

    To configure a shutdown script by group policy:

    1. create a OU, and add those computer accounts, which need run the script

    2. put the script on a shared folder and computer related permission for the folder(to make sure the script could be run on those computer)

    3. create a GPO and link the GPO to the computer OU

    4. configure the shutdown script under the path Computer Configuration\Policies\Windows Settings\scripts

    5. double-lick the shutdown, click add and fill with UNC path

    6. try to run gpudpate /force on client computer to apply group policy

    In addition, here is an article below about how to configure shutdown script for your reference.

    Assign Computer Shutdown Scripts

    https://technet.microsoft.com/en-us/library/cc770300(v=ws.11).aspx

    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.

    Thursday, January 12, 2017 8:26 AM
    Moderator
  • Thank you for your advice. I didn't think at the begining that policy for the computer, should be connected to OU with computers. I linked the policy to OU with users.

    Right now  I created new OU for computer, moved one of them for test, and it's clearing the Temp.

    That is no difference where the computer are? In witch container? Becouse i had them in built-in computer container by default.

    Thursday, January 12, 2017 12:50 PM
  • The GPO will be applied only on computers under the OU where is linked and in its scope (Meaning it should the computer should have read and apply group policy permissions applied). Without that, your script won't get executed.

    This posting is provided AS IS with no warranties or guarantees , and confers no rights.

    Ahmed MALEK

    My Website Link

    My Linkedin Profile

    My MVP Profile

    Thursday, January 12, 2017 10:40 PM
  • Hi Ernest,

    I've pasted the bat file to DC Sysvol lacation, and I've configured shutdown script in GPO Computer Configuration.

    When i reboot my computer it doesn't clean Temp location.

    Right now  I created new OU for computer, moved one of them for test, and it's clearing the Temp.

    That is no difference where the computer are? In witch container? Becouse i had them in built-in computer container by default.

    >>>If you configure the script under Computer Configuration, and the GPO link to an USERS OU, the group policy will not work.

    Because, the setting of Computer Configuration only work for computers instead of user.

    To achieve your goal, you need link the GPO to a COMPUTERS OU.

    If you want all computers in the domain apply the policy, you could configure the startup script under default domain policy.

    If you just want some computers in the domain, please follow the steps which I provided above to configure it.

    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.

    Thursday, January 19, 2017 7:43 AM
    Moderator
  • 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.

    Monday, January 23, 2017 6:12 AM
    Moderator