phillyman2004 Posted August 20, 2005 Posted August 20, 2005 I need to put a line into my batch files like this ------------------------------------------------If path/done.dat existsEXITElse...do something rename path/blank.dat to path/done.dat--------------------------------------------------So that this file will only execute if done.dat doesnt existIs there a way to do this with a batch fileThanks for the helpRob
dman Posted August 20, 2005 Posted August 20, 2005 (edited) try...IF EXIST <path\file> GOTO DONE stuff to do if path not exist....:DONEEDIT- Go Eagles! Edited August 20, 2005 by dman
Yzöwl Posted August 20, 2005 Posted August 20, 2005 (edited) IF NOT EXIST "drive\path\blank.dat" ( IF EXIST "drive\path\done.dat" ( REN "drive\path\done.dat" "blank.dat" ))<Edit>This way it ensures that if the file doesn't already exist it will only rename it if the file you wish to use for the rename procedure exists.</Edit> Edited August 20, 2005 by Yzöwl
MHz Posted August 21, 2005 Posted August 21, 2005 Here is another If structureIf Exists path/done.dat (Exit) Else If Exist path/blank.dat (rename path/blank.dat path/done.dat) Else (do something )
gunsmokingman Posted August 21, 2005 Posted August 21, 2005 Here is the vbs way it checks to see if Winamp Is installed Dim Act, Fso, SD Set Act = CreateObject("Wscript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") SD = Act.ExpandEnvironmentStrings("%SystemDrive%") If Not Fso.FileExists( Chr(34) & SD & "\Program Files\Winamp\winamp.exe" & Chr(34))Then Act.Popup "Winamp Is Not Installed" & vbCrLf & "Preparing To Exit", 5, "Missing", 0 + 32 Else Act.Popup "Winamp Is Install" ,5, "Confimed", 0 + 32 End If
new_user Posted August 21, 2005 Posted August 21, 2005 (edited) Wow i see ... quick resolutions for a question But what about my problem ? No replies I simply search for a utility (batch) for my unattended CD1. Reserve drive Letter C,D,E for Harddisk partitionsdedect CD/RW and DVD-ROM2. Assign my first DVD (Master Drive) the drive letter F: and the CD-RW (Slave Drive) the drive letter G:Is there no batch in your pocket for my problem ??? Yzöwl, MHz, gunsmokingman Thank you in advance Edited August 24, 2005 by new_user
Dahi Posted August 22, 2005 Posted August 22, 2005 newuser,Search for DISKPART. You can script Diskpart to modify partitions and change drive letters.
Jito463 Posted August 22, 2005 Posted August 22, 2005 IF NOT EXIST "drive\path\blank.dat" ( IF EXIST "drive\path\done.dat" ( REN "drive\path\done.dat" "blank.dat" ))<Edit>This way it ensures that if the file doesn't already exist it will only rename it if the file you wish to use for the rename procedure exists.</Edit><{POST_SNAPBACK}>That's what I used for a "hack job" on one of my batch files while I tried to find a way to prevent it from running after sysprep (silly me, I forgot to include the sysprep,inf, heh). I just copied a file to the root of the drive during the preinstall and deleted it after resealing the machine for the customer. If it existed, the batch file ran and installed the applications. If it did not exist (after resealing), the batch file would simply exit.
new_user Posted August 22, 2005 Posted August 22, 2005 @Dahisorry about my post here. I could not find a good solution for my problem.But i saw a lot of fantasic scripts from Yzöwl, MHz and gunsmokingman And i thought maybe they have a script for my driveletter problem too.Please ???There is still no reply from mdes Mapdrive
gunsmokingman Posted August 23, 2005 Posted August 23, 2005 Here a VBS script that will count your drives.It will not count the drives if this file exists SD & "\TestMe.txt" If it does not exist then it count your drivesCheck For File On SystemDriveDim Act, Cnt, Drv, FsoSet Fso = CreateObject("Scripting.FileSystemObject")Set Act = CreateObject("Wscript.shell")Dim SD : SD = Act.ExpandEnvironmentStrings("%systemdrive%")Cnt = 1-1Set Drv = Fso.DrivesFor Each strD In Drv If strD.DriveType = 2 ThenIf Not Fso.FileExists(SD & "\TestMe.txt") Then''''Place Action Here for if it not thereCnt = Cnt +1Act.Popup "This Is, " & strD & ", Harddrive" & vbCrLf & "Count Number = " & Cnt, 3, "Count Drives", 0 + 32Else'''' Place Another Here for if it thereAct.Popup "It Was There", 3, "Confirm", 0 + 32Exit ForEnd IfEnd IfNextChecks if the TestMe.txt file is on any of the Harddrives or PartitionDim Act, Cnt, Drv, FsoSet Fso = CreateObject("Scripting.FileSystemObject")Set Act = CreateObject("Wscript.shell")Dim SD : SD = Act.ExpandEnvironmentStrings("%systemdrive%")Cnt = 1-1Set Drv = Fso.DrivesFor Each strD In Drv If strD.DriveType = 2 ThenIf Not Fso.FileExists(strD & "\TestMe.txt") Then''''Place Action Here for if it not thereCnt = Cnt +1Act.Popup "There Was No TestMe.txt 0n, " & strD & Vbcrlf & "Count Number = " & Cnt, 3, "Count Drives", 0 + 32Else'''' Place Another Here for if it thereAct.Popup "It Was There In This Location" & vbCrLf & strD & "\TestMe.txt", 3, "Confirm", 0 + 32Exit ForEnd IfEnd IfNextThese VBS scripts use the If not Exists statement to check for the fileTested the script and it works 100% on my computer.Hope this helps.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now