How To

Remove Virus/unwanted file Using Command Prompt

Hi, friend I know that almost everyone who is using computer must be having antivirus installed on their system and some of them may not. But sometime it happens that your antivirus doesn’t detect virus even though you have 100% doubt that your Pendrive must have virus because you brought your Pendrive from somewhere like cyber cafe, PC from where there is no antivirus installed, etc.

Now in this case you must follow the steps given below to check unwanted files and folder in your PenDrive and delete it.

Note that, this trick can also be use to remove unwanted files/folders from your Drive too.

Follow the steps to remove unwanted Files from your Pendrive/ Drive without opening it:

  1. Insert your Virus infect Pendrive and Scan for virus, if detected then well and good otherwise go ahead to remove it from command prompt.

In my case it has detected the virus even though I would like show you, how to remove this virus using command prompt?


  1. As you can see that antivirus installed on my system has detected “autorun.inf” file.

This is the file; if you try to open it then your system may get infected with virus.

  1. So, let us remove it from command prompt.

Open command prompt and go to the virus infected drive by typing “Drive name with colon” (H: ) then enter.

Now type attrib -s -h *.* /s /d and enter. And continue by typing “dir” which will show you all files/folders in that drive, as you can see that files is present in this drive.


  1. Now if you want to delete it then just type “RD name of file/folder to be deleted)” or rename it to delete it manually.

To rename the file just type in command prompt

REN “Path of files/folder to be deleted” (space) “Name to be given”

Or if you are in that drive using command prompt then type

REN “Name of files to be deleted” (space) “Name to be given”



Worth Reading : Recover any type of deleted files from Pendrive or Hard Disk.

  1. Now you can check that has been rename as useless


  1. Now if you will scan then your antivirus won’t detected virus in that drive.


  1. Now if you want then you can delete this file after opening the drive.



You may not go for such a large procedure to delete any virus affected file if you have daily updated antivirus. But this is quite useful when one of your folder is giving you trouble by hanging your system when you open that folder.

Please let us know through comment box, if you have any other trick to share with our reader.


Want to get similar cool tech stuffs in you Inbox? Subscribe to my Feed!


      1. but how wud i knw tht certain number of files in any drive contains certain number of files .
        i dnt use any of the antiviruses till now .viruses may be of any name .
        plz tell me as fast as possible.

        1. Author

          Hi Shivam,

          Many time you will notice that there are shortcut files created in your system and you can also delete those shortcut files but some files don’t get deleted. And there are some files which misbehave when clicked on it.

          Such type of files can be remove using this trick. If you have paid antivirus then you can scan your system using that antivrus but if you are using a free version then such files dont get delete mostly. So you can use this trick.

          Hope this will help you.

          Thanks for coming by and commenting.

          Have a great day ahead! 🙂

          >SK Lohar
          Shivkumar recently posted…Transfer files at highest speed using Wifi File transferMy Profile

  1. Hi Shivkumar,

    This post is a keeper! Just last week my computer was making a weird sound and when I looked, it was a virus attack. Lucky for me, I just closed everything down immediately. Then I ran a virus scan. All was well. But what have happened if I wasn’t so lucky?

    I would sure need this post!

    Thanks so much, I have bookmarked this just in case I run into trouble again.

    Donna Merrill recently posted…3 Ways To Pump Up Your BlogMy Profile

  2. Hi. I have a problem on my laptop computer. It always gives me this Windows Script Host error message on start-up:[cannot find script file “C\Users\HP User\App Data\Roaming\Adobe\flash player\cache\IDM cache.vbs”]
    This started after I manually deleted a left-over file of Internet Download Manager from my computer (after uninstalling IDM). The remainder files of the “IDM cache.vbs” are no longer in my recycle bin. Please how do I fix this error message? can it be fixed from the command prompt window?

    NB: IDM cache.vbs” error has been a common problem with many computer users (as I’ve discovered on the internet recently).

      1. Hi. NOTE that all the files related to the missen script file have been removed by Advanced Uninstaller after I had used RevoUninstaller to uninstall IDM earlier on. So right now, How do I still check for left-over files relating to the missen script file with Revo uninstaller ?

  3. Hey I can do this method…
    This method is have any side effect on my PC???
    This process is not affect the data stored in PC means format???
    Sorry for my bad English…
    but plz reply me fast I am waiting???

  4. Guys the method works with any side effect you can go ahead and use it don’t fear

    And how about to close programmers using cmd

    1. Author

      Hi Sreekanth,

      Since you are using free antivirus, you may not be able to remove virus completely from your system. I would suggest to get a lincence copy of antivirus if you really care about your data and keep it up to date.

      Tricks like removing virus may help to certain extend but it may not be able to rectify recent virus came in market.

      Thanks for coming by and asking for help.

      Have a great day ahead! 🙂

      >SK Lohar
      Shivkumar recently posted…Simple but useful keyboard shortcuts in window 7 –Part 3My Profile

    1. Author

      Hi Brandon,

      Did you tried with steps mention in above article?

      If you still facing the issue you can use
      and uninstall unwanted app.

      Please make a note that all this method may or may not work sometime due to vulnerability of virus. Hence paid antivirus should be the first choice. 😉

      Thank for coming by and asking for help.

      Have a great day ahead! 🙂

      >SK Lohar
      Shivkumar recently posted…Disable PC USB port and increase your system security in 2 minutesMy Profile

  5. recently a virus attacked me and after every minute command prompt pops up. My browser settings are changed and lots of Japanese softwares just got installed. My antivirus can`t detect it. what should i do?

  6. i have 8gb mem and it is infected by some corrupt files….i have scanned it in my pc antivirus… quick heal anitvirus…… but it didnot repaired them it skiped the archive files…… how can i delect those corrupt files….can u please guide me

    1. Author

      Hi Singh,

      If you are using a paid version of Quick Heal Antivirus then it will detect those corrupted files. If it didn’t detect, did u tried formatting the memory card?

      I will be writing about an awesome tool to format memory card which will repair memory card in single. You can subscribe my blog subscription box present at end of this post. So that you won’t miss my post.

      Thanks for coming by.
      Have a great day! 🙂

      >SK Lohar
      Shivkumar recently posted…Xnspy: Spy app to spy all private data for Android and iOS SmartPhoneMy Profile


Post Comment

CommentLuv badge