August 20, 200521 yr 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
August 20, 200521 yr try...IF EXIST <path\file> GOTO DONE stuff to do if path not exist....:DONEEDIT- Go Eagles! Edited August 20, 200521 yr by dman
August 20, 200521 yr 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, 200521 yr by Yzöwl
August 21, 200521 yr 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 )
August 21, 200521 yr 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
August 21, 200521 yr 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, 200521 yr by new_user
August 22, 200521 yr newuser,Search for DISKPART. You can script Diskpart to modify partitions and change drive letters.
August 22, 200521 yr 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.
August 22, 200521 yr @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
August 23, 200521 yr 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.
Create an account or sign in to comment