/build/static/layout/Breadcrumb_cap_w.png

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 8 years ago

Answers (3)

Posted by: SMal.tmcc 8 years ago
Red Belt
1
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"





Comments:
  • the parameters: /c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G" - SMal.tmcc 8 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 8 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 8 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 8 years ago
      • /C is not a recognized internal or external command, operable command or batch - CEads 8 years ago
      • the /c is a switch only for when you call cmd from another app. start with the "for" statement - SMal.tmcc 8 years ago
      • for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G" - SMal.tmcc 8 years ago
      • run the above in the cmd window - SMal.tmcc 8 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 8 years ago
    • maybe they fixed some bug in the latest Kace release, I am running 6.4 RC - SMal.tmcc 8 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 8 years ago
Posted by: htomlinson 8 years ago
Purple Belt
0
I'm assuming your having issues with the username and domain being unique?
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 8 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 8 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 8 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 8 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 8 years ago
    • %userdomain% only returns the short name not fqdn try %userdnsdomain% - SMal.tmcc 8 years ago
    • also you may want to switch to rd /s /q "C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\%USERNAME%@%USERDNSDOMAIN%" - SMal.tmcc 8 years ago
  • the final path is: first.lastname@dominname.com So it wont find username as the username and email address is different - CEads 8 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 8 years ago
    • are there any other dirs that end with the domain.com in the history directory that you need to keep? - SMal.tmcc 8 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 8 years ago
Posted by: SMal.tmcc 8 years ago
Red Belt
0
try it as a online kscript like this



Comments:
  • rd /q /s "%localappdata%\Cisco\Unified Communications\Jabber\C
    SF\History\%USERNAME%@%USERdnsDOMAIN%" - SMal.tmcc 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ