0

Here is my code (delete_thumbs.vbs):

Dim str
str = InputBox("Enter the path from where you want to delete thumbs")
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /K CD /d & str"

I am willing to get the user input for the path of the folder by prompting them to enter the path using InputBox and then execute a command to delete all the Thumbs.db located in that folder.

Command to delete Thumbs.db

del /s /q /f /a:h Thumbs.db

The problem I am facing is that when I run "delete_thumbs.vbs" it prompts for user input to enter path of the folder but after the path is entered its not getting detected in CMD and it just prompts:

The system can not find the path specified

C:/Users/user/Desktop

Please guide me.Where am I going wrong

  • 3
    may you'll want to check this question - http://stackoverflow.com/questions/15885132/file-folder-chooser-dialog-from-a-windows-batch-script – npocmaka Apr 22 '16 at 13:04
  • 1
    Shouldn't it be more like `oShell.run "cmd /K CD /d " & str` if you are trying to add the content of the variable `str` to the command? But why use a batch command in the first place? – Fred Apr 22 '16 at 13:09
  • After I delete thumbs from the folder I need to run a sync program Synctoy thats why I decided to use batch command. I edited as Fred suggested. Now I am able to directly reach to the folder path given by user: For example: D:/Data/Volume1> – Scroll Lock Apr 22 '16 at 14:39
  • Now one last step is pending, that is to enter the command (del /s /q /f /a:h Thumbs.db) to delete thumbs.db in that folder. How can I do that? I tried by doing this and several other methods: {oShell.run "cmd /K CD /d" & str & del /s /q /f /a:h Thumbs.db} But its not working. – Scroll Lock Apr 22 '16 at 14:50
  • Can somebody please help me resolve this. I really need your help. – Scroll Lock Apr 22 '16 at 16:26

0 Answers0