So here is the scoop. I want to make a script to delete the temp folder in each users profile C:\\Users\\Default\\AppData\\Local\\Temp). We have about 10 user profiles on each pc so manually doing this just isn’t in my wish list.<\/p>\n
What would be the best way to capture each user profile name and insert it into a delete command? My thought was to somehow output a “dir” command to a text file and suck it into a looping script to del C:\\Users%username%\\AppData\\Local\\Temp\\ but I dont have any idea of how to do that.<\/p>\n
Thanks in advance.<\/p>","upvoteCount":6,"answerCount":11,"datePublished":"2013-05-28T13:38:05.000Z","author":{"@type":"Person","name":"tonystahl","url":"https://community.spiceworks.com/u/tonystahl"},"acceptedAnswer":{"@type":"Answer","text":"
Set fso = CreateObject(\"Scripting.FileSystemObject\")\nSet base_folder = fso.GetFolder(\"C:\\Users\\\")\nSet folders = base_folder.SubFolders\n \nFor Each folder In folders\n \n If fso.FolderExists(folder & \"\\AppData\\Local\\Temp\") Then\n\n fso.DeleteFolder folder & \"\\AppData\\Local\\Temp\\*\"\n fso.DeleteFile folder & \"\\AppData\\Local\\Temp\\*\"\n\n End If\n\nNext\n<\/code><\/pre>\nHeres a start.<\/p>","upvoteCount":3,"datePublished":"2013-05-28T13:43:41.000Z","url":"https://community.spiceworks.com/t/need-help-on-a-script/215400/3","author":{"@type":"Person","name":"craigduff","url":"https://community.spiceworks.com/u/craigduff"}},"suggestedAnswer":[{"@type":"Answer","text":"
So here is the scoop. I want to make a script to delete the temp folder in each users profile C:\\Users\\Default\\AppData\\Local\\Temp). We have about 10 user profiles on each pc so manually doing this just isn’t in my wish list.<\/p>\n
What would be the best way to capture each user profile name and insert it into a delete command? My thought was to somehow output a “dir” command to a text file and suck it into a looping script to del C:\\Users%username%\\AppData\\Local\\Temp\\ but I dont have any idea of how to do that.<\/p>\n
Thanks in advance.<\/p>","upvoteCount":6,"datePublished":"2013-05-28T13:38:05.000Z","url":"https://community.spiceworks.com/t/need-help-on-a-script/215400/1","author":{"@type":"Person","name":"tonystahl","url":"https://community.spiceworks.com/u/tonystahl"}},{"@type":"Answer","text":"
http://gallery.technet.microsoft.com/scriptcenter/Delete-Temp-files-2f2438f1<\/a><\/p>","upvoteCount":0,"datePublished":"2013-05-28T13:42:13.000Z","url":"https://community.spiceworks.com/t/need-help-on-a-script/215400/2","author":{"@type":"Person","name":"grahampocta","url":"https://community.spiceworks.com/u/grahampocta"}},{"@type":"Answer","text":"That link will help get you started with a vbscript – you might need to add a bit to get the Appdata\\local\\temp folder deleted as well, but this gives you the necessary syntax, etc.<\/p>","upvoteCount":0,"datePublished":"2013-05-28T13:43:42.000Z","url":"https://community.spiceworks.com/t/need-help-on-a-script/215400/4","author":{"@type":"Person","name":"grahampocta","url":"https://community.spiceworks.com/u/grahampocta"}},{"@type":"Answer","text":"
Set it up as a script that runs at logoff via GPO.<\/p>\n
del %userprofile%\\Appdata\\local\\temp .<\/em> /y<\/p>","upvoteCount":0,"datePublished":"2013-05-28T13:45:46.000Z","url":"https://community.spiceworks.com/t/need-help-on-a-script/215400/5","author":{"@type":"Person","name":"rockn","url":"https://community.spiceworks.com/u/rockn"}},{"@type":"Answer","text":"