How to delete all files from a folder using VB Shell

Asked

Viewed 1,501 times

-2

I’m trying like this and I can’t:

Shell("CMD.exe /c ""C:\Users\""%username%""\AppData\Local\Google\Chrome\""User Data""\Default\Cache\DEL *.* /Q""  ")

In this case the folder is the Googlechrome cache

NO DOS I use so:

CD C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cache\*.* /q
pause
  • I don’t see the use of del, nor of rmdir/Rd to remove the content in this example. The cd is to change directory and not to delete files.

  • @ararog can help me with an example ?

  • del C: Users%username% Appdata Local Google Chrome User Data Default Cache\.

  • @ararog like this one I made to run a txt file I’ll send you the code if I put a 1.txt file inside the cache it opens I don’t know how to use the deleted downloaded ? I don’t know how to put it on the line , The command I use to open is like this , Shell("CMD.exe /c ""C: Users"%username%"" Appdata Local Google Chrome"""User Data"" Default Cache 1.txt"" ")

  • @ararog I will test here , Erai.

  • @ararog went bad, he did not execute the command, something is wrong on the written line.

  • @ararog I’ll take the print

  • @ararog I wrote the code so

  • @ararog Shell("CMD.exe del C: Users%username% Appdata Local Google Chrome User Data Default Cache*.*") Error image link : http://i.imgur.com/Cbvow7g.png

  • Instead of %username.

  • @ararog nothing same, gave error again the same image error.

Show 6 more comments

1 answer

3

First, this is a CMD (command line) question, as the language used to call the CMD is irrelevant to the question in question.

Second, we can not assume that Chrome will be on disk C:

So the right place is %LOCALAPPDATA%, which already has all the details for the current user folder. This is if Chrome is installed at the default place. Ideally search for the registry.

Simply put, using the logic of the question, the line would have to stay this way:

Shell("CMD.exe /c DEL /q ""%LOCALAPPDATA%\Google\Chrome\User Data\Default\Cache\*.*"" ")

Now, between us, if it is to use VB, it would compensate a procedure in VB even to clean the directory, instead of calling the CMD...

  • thanks ; hopefully it works is because the delete command has to be running from within Vb just for that. I know how to call an external command but didn’t want to use it in the application .

  • Soon you will understand why this command .

  • how can I delete a file for example inside that folder. %LOCALAPPDATA% Google Chrome User Data Default The file you wanted to delete is History

  • @Perroni same thing, only it changes \Default\Cache\*.*"" " for \Default\History"" "

Browser other questions tagged

You are not signed in. Login or sign up in order to post.