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

Comments

  • 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
Please log in to comment

Community Chosen Answer

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"




Answered 06/30/2015 by: SMal.tmcc
Red Belt

  • the parameters: /c for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*tmccadmn.edu") do rd /s /q "%~G"
    • 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] -----
      • 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.
      • 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
      • /C is not a recognized internal or external command, operable command or batch
      • the /c is a switch only for when you call cmd from another app. start with the "for" statement
      • for /d %G in ("%localappdata%\Cisco\Unified Communications\Jabber\CSF\History\*benefitfocus.com") do rd /s /q "%~G"
      • run the above in the cmd window
  • 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.
    • maybe they fixed some bug in the latest Kace release, I am running 6.4 RC
    • 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"
Please log in to comment

Answers

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%"
Answered 06/29/2015 by: htomlinson
Purple Belt

  • 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
    • 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.
      • 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%
      • do like htomlinson suggests, run it as logged in user, running as administrator will look at the administrators profile not the users.
  • All items remain when executing the script as the logged in user. the problem is the final path isnt found %USERNAME%@%USERDOMAIN%
    • %userdomain% only returns the short name not fqdn try %userdnsdomain%
    • also you may want to switch to rd /s /q "C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\%USERNAME%@%USERDNSDOMAIN%"
  • the final path is: first.lastname@dominname.com So it wont find username as the username and email address is different
    • 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.
    • are there any other dirs that end with the domain.com in the history directory that you need to keep?
      • 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
Please log in to comment
This content is currently hidden from public view.
Reason: Removed by member request
For more information, visit our FAQ's.

0
try it as a online kscript like this


Answered 06/30/2015 by: SMal.tmcc
Red Belt

  • rd /q /s "%localappdata%\Cisco\Unified Communications\Jabber\C
    SF\History\%USERNAME%@%USERdnsDOMAIN%"
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share