How to delete all files in a folder using the VB Shell

-2

I'm trying this and I can not:

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

In case the folder is that of the Google Chrome cache

In DOS I use this way:

CD C:\Users\%username%\AppData\Local\Google\Chrome\User Data\Default\Cache\*.* /q
pause
    
asked by anonymous 28.09.2014 / 16:32

1 answer

3

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

Second, you can not assume Chrome will be on C:

Thus, the correct location is %LOCALAPPDATA% , which already has all the details for the current user's folder. That's if Chrome is installed in the default place. Ideally you should look for the registry.

Simply put, using the logic of the question, the line would have to look like this:

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 ...

    
28.09.2014 / 17:55