DOS commands

Maybe I should elaborate a bit more about the problem I'm trying to solve :)

I'm right now using a program called "USBVirusScan" that runs any command I want whenever a drive is plugged into the PC.

So I made a script that checks all the drives in the PC for autorun.inf to get rid of any potential viruses because I swop flash discs in and out of my pc A LOT.

It works 100% except for the fact that it runs whenever a CD is inserted as well, and naturally windows pops up with a error when my script tries to delete the autorun.inf file, very annoying.

Does anyone have any suggestions or maybe a better program that could do the job?

Even if I get that chkntfs problem on my pc fixed I would still have to do some string manipulation and that is not one of my better hobbies...
 
I can disable the autorun, but I would prefer to delete the file so that it does not infect another pc.
 
Even though you have this solved.. How do you get a variable from a file in dos to be used by another command? If I could ask :)
 
Well lets say you run this command:

fsutil fsinfo drivetype

It returns with info stating if the drive is fixed, removeable or a CD-rom.

Could you pass that value from the above into a script to check and then run your program if it is NOT a cd-rom? If that makes sense :)
 
dump the info from fsutil using "fsutil fsinfo drivetype c: >> info.txt"

Then in the batch script use the following to create a variable and assign it the contents of info.txt: "set /p myvar= < info.txt"

hope this helps
 
Cool :) So would you of been able to use that command then to run your script?

Basically stating that "if myvar= CD-rom" then dont scan the drive?
 
Cool :) So would you of been able to use that command then to run your script?

Basically stating that "if myvar= CD-rom" then dont scan the drive?

I dunno if it would work cos once the info is dumped into a text file and read back into a variable then it would look like "f: - CD-ROM Drive" and then you would have to have some sort of string manipulation to extract the "CD-ROM" part of the string and I've got no idea on how to do that.
 
I dunno if it would work cos once the info is dumped into a text file and read back into a variable then it would look like "f: - CD-ROM Drive" and then you would have to have some sort of string manipulation to extract the "CD-ROM" part of the string and I've got no idea on how to do that.

Dos tools are a bit limited. The only solution is to install unix tools for Windows, and then you can use grep and awk.
 
I dunno if it would work cos once the info is dumped into a text file and read back into a variable then it would look like "f: - CD-ROM Drive" and then you would have to have some sort of string manipulation to extract the "CD-ROM" part of the string and I've got no idea on how to do that.

Ok tested something with this

fsutil fsinfo drivetype C: >> c:\info.txt
set /p myvar= < c:\info.txt
echo.%myvar%
set myvar=%myvar:~5,2%
echo.%myvar%

If its afixed drive it will return "FI"
If its a removable drive it will return "RE"
and lastly if its a CD/DVD it will return "CD"

You could then use that to run your program if you need.
Not needing it myself, just bored at work so wanted to work out how your original script could be done.
 
Top
Sign up to the MyBroadband newsletter
X