Help Deleting items within a folder using a script from Kace
I am trying to delete items within a folder on Windows 7 x64 machines using a Script. I have created mutipile vbs & batch script in the past to delete temp folders and Office temp folders but the path to this directory is a unique one and i believe it is where I am running into a blocker. The path to the directory is C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\myuseranme@domainname.com and the items deleted within the folder. I can get the script to delete the C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History but we must keep the subfolders and files located under the history folder. I just need to dlete the items under C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\myuseranme@domainname.com
1 Comment
[ + ] Show comment
-
I believe the issue is with the path. From the command prompt i try to browse to the location and it cant be found: C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History - CEads 9 years ago
Answers (3)
Please log in to answer
Posted by:
SMal.tmcc
9 years ago
ok try this as a online kscript or shell. Just put your domain in the place of mine.
for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G"
for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G"
Comments:
-
the parameters: /c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G" - SMal.tmcc 9 years ago
-
Thanks for the help, same result however. Tried both KScript and shell but all items remain Below are the logs Activity Log
Launching program: 'C:\Windows\System32\cmd.exe' '/c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G"' wait='false'
Launching program: 'C:\Windows\System32\cmd.exe' '/c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G"' wait='false'
Debug Log
Running kbot: runkbot 2307 1435697019
Kbot Config Info - Start
id=2307 name=Delete CIsco Jabber Logs version=1435697019 type=policy
execute disconnected=false logged_off=false
execute events
Kbot Config Info - Finish
runkbot ----- launching [path='C:\Windows\System32' program='cmd.exe' parms='/c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G"' wait='false'] -----
runkbot ----- completed [exitCode=0] -----
runkbot ----- launching [path='C:\Windows\System32' program='cmd.exe' parms='/c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G"' wait='false'] -----
runkbot ----- completed [exitCode=0] ----- - CEads 9 years ago-
That is strange, I ran that on my kbox as a online kscript against my computer as logged in user and I watched it delete the directory I created there. - SMal.tmcc 9 years ago
-
try on a machine open a cmd window as a user with that directory and paste for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G" in the window and run it and see what happens - SMal.tmcc 9 years ago
-
/C is not a recognized internal or external command, operable command or batch - CEads 9 years ago
-
the /c is a switch only for when you call cmd from another app. start with the "for" statement - SMal.tmcc 9 years ago
-
for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G" - SMal.tmcc 9 years ago
-
run the above in the cmd window - SMal.tmcc 9 years ago
-
Gets even stranger. The command from the command prompt and it works. I create the script just as you did (shell & OnLine) and the folder remains. So i create a batch script, execute as myself and as an admin and the folder remains. - CEads 9 years ago
-
maybe they fixed some bug in the latest Kace release, I am running 6.4 RC - SMal.tmcc 9 years ago
-
I created an Online Kscript, checked enabled, selected specific OS's, Put my machine in Devices, Choose under "Windows Run As" Logged-in user, Under task1-verify choose "Launch a program", Directory: $(KACE_SYS_DIR), File: cmd.exe Parameters: /c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G" - SMal.tmcc 9 years ago
Posted by:
htomlinson
9 years ago
I'm assuming your having issues with the username and domain being unique?
Could you use:
Could you use:
an online shell script to run
DEL /Q /F "C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\%USERNAME%@%USERDOMAIN%"
Comments:
-
Thanks for the response. Yes the issue is with the username and domain being unique and i tried the command you posted and all i get is the dos splash screen and the folder still remains - CEads 9 years ago
-
This may seem silly but are you running the script as the "local system" if so then the username variable will not work. The script can only be run as current logged-in user or as all logged-in users. - htomlinson 9 years ago
-
running it as an administrator, I am a local admin on my machine. I am executing the script locally before loading into kace, after trying multiple variation i believe it must be the unique %USERNAME%@%USERDOMAIN% - CEads 9 years ago
-
do like htomlinson suggests, run it as logged in user, running as administrator will look at the administrators profile not the users. - SMal.tmcc 9 years ago
-
All items remain when executing the script as the logged in user. the problem is the final path isnt found %USERNAME%@%USERDOMAIN% - CEads 9 years ago
-
the final path is: first.lastname@dominname.com So it wont find username as the username and email address is different - CEads 9 years ago
-
Then write a VB script to do it. You can either step through a list of usernames or you could do a wildcard deletion of folders in that sub-folder to delete all of them.
If you need to know how to that google it. - htomlinson 9 years ago -
are there any other dirs that end with the domain.com in the history directory that you need to keep? - SMal.tmcc 9 years ago
-
No, i just need all items under (username@domainname.com) deleted. Also the above actions using rd & the DEL command do not remove the items, the script execute and says successfull but all items remain. Created the scipt using the del & rd command and using an online kscript + shell script - CEads 9 years ago