Jump to content

Batch File Help (Possilbe Variable?)


phillyman2004

Recommended Posts

I have a batch file that updates my flash drive , Problem is that on different computers my Flash drive shows up as different Drive letters

So i have 50 lines of code that has to be hard coded , is there a way i can do something like this

IF EXIST D:\start.dat (

%variable% = D:

)

IF EXIST E:\start.dat (

%variable%= E:

)

copy C:\updates "%variable%\path\to\updates\"

I just hate to have to write the code over and over 7-9 times to cover the possibilities of my flash drive volume letter and then use a gigantic IF statement

Link to comment
Share on other sites


FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\start.dat SET Tdrive=%%i:
copy c:\updates "%tdrive%\path\to\updates

Thanks for that , Any Clue why now after i am using a variable the copy function keeps telling me that Access Is Denied?

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\start.bat SET Tdrive=%%i:


copy /y "C:\updates\defs\*.*" "%tdrive%\Help\Spyware\Ad-Aware"


copy /y "C:\updates\defs\*.*" "%tdrive%\Help\Spyware\Laser\Ad-Aware"


copy /y "C:\updates\fpdef\*.*" "%tdrive%\Help\Virus\Command Line Scanners\F-Prot\F-Prot CLS\"
copy /y "C:\updates\macrdef2\*.*" "%tdrive%\Help\Virus\Command Line Scanners\F-Prot\F-Prot CLS\"

copy /y "C:\updates\fpdef\*.*" "%tdrive%\Help\Virus\Command Line Scanners\F-Prot\F-Prot for DOS\"
copy /y "C:\updates\macrdef2\*.*" "%tdrive%\Help\Virus\Command Line Scanners\F-Prot\F-Prot for DOS\"


del "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\Sysclean\*.*"
copy /y "C:\updates\lptdef\*.*" "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\Sysclean\"
copy sysclean.com "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\Sysclean\"

del "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\VSCANTM\tmaptn.*
del "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\VSCANTM\lpt$vpn.*
copy /y "C:\updates\lptdef\*.*" "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\VSCANTM\"
copy /y "C:\updates\tmadef\*.*" "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\VSCANTM\"


copy "C:\updates\tsc\*.*" "%tdrive%\Help\Virus\Command Line Scanners\Trend Micro\DCE.DCT"



copy /y "C:\updates\mcafee" "%tdrive%\Help\Virus\Command Line Scanners\McAfee\"


del "%tdrive%\Help\Virus\Product Updates\Symantec\2006****-***-i32.exe"
copy /y 2006****-***-i32.exe "%tdrive%\Help\Virus\Product Updates\Symantec\"


del "%tdrive%\Help\Virus\Product Updates\McAfee\sdat****.exe"
copy sdat****.exe "%tdrive%\Help\Virus\Product Updates\McAfee\sdat****.exe"


del "%tdrive%\Help\Spyware\Spy Sweeper\masters.mst"
copy masters.mst "%tdrive%\Help\Spyware\Spy Sweeper\"

Link to comment
Share on other sites

the only thing I can think of is if the files already in the target folder are set to ready only. Then you will get an Access Denied Error when trying to copy over them.

Or if you thumbdrive is set to read only.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...