Jump to content

Recommended Posts

Posted

I need to put a line into my batch files like this

------------------------------------------------

If path/done.dat exists

EXIT

Else...

do something

rename path/blank.dat to path/done.dat

--------------------------------------------------

So that this file will only execute if done.dat doesnt exist

Is there a way to do this with a batch file

Thanks for the help

Rob


Posted (edited)

try...

IF EXIST <path\file> GOTO DONE

   stuff to do if path not exist....

:DONE

EDIT- Go Eagles!

Edited by dman
Posted (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 by Yzöwl
Posted

Here is another If structure

If Exists path/done.dat (
Exit
) Else If Exist path/blank.dat (
rename path/blank.dat path/done.dat
) Else (
do something
)

Posted

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

Posted (edited)

Wow i see ... quick resolutions for a question :thumbup

But what about my problem ? No replies

I simply search for a utility (batch) for my unattended CD

1. Reserve drive Letter C,D,E for Harddisk partitions
dedect CD/RW and DVD-ROM
2. 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 by new_user
Posted
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>

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.

Posted

@Dahi

sorry 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 :thumbup

And i thought maybe they have a script for my driveletter problem too.

Please ???

There is still no reply from mdes Mapdrive

Posted

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 drives

Check For File On SystemDrive

Dim Act, Cnt, Drv, Fso

Set Fso = CreateObject("Scripting.FileSystemObject")

Set Act = CreateObject("Wscript.shell")

Dim SD : SD = Act.ExpandEnvironmentStrings("%systemdrive%")

Cnt = 1-1

Set Drv = Fso.Drives

For Each strD In Drv

If strD.DriveType = 2 Then

If Not Fso.FileExists(SD & "\TestMe.txt") Then

''''Place Action Here for if it not there

Cnt = Cnt +1

Act.Popup "This Is, " & strD & ", Harddrive" & vbCrLf & "Count Number = " & Cnt, 3, "Count Drives", 0 + 32

Else

'''' Place Another Here for if it there

Act.Popup "It Was There", 3, "Confirm", 0 + 32

Exit For

End If

End If

Next

Checks if the TestMe.txt file is on any of the Harddrives or Partition

Dim Act, Cnt, Drv, Fso

Set Fso = CreateObject("Scripting.FileSystemObject")

Set Act = CreateObject("Wscript.shell")

Dim SD : SD = Act.ExpandEnvironmentStrings("%systemdrive%")

Cnt = 1-1

Set Drv = Fso.Drives

For Each strD In Drv

If strD.DriveType = 2 Then

If Not Fso.FileExists(strD & "\TestMe.txt") Then

''''Place Action Here for if it not there

Cnt = Cnt +1

Act.Popup "There Was No TestMe.txt 0n, " & strD & Vbcrlf &  "Count Number = " & Cnt, 3, "Count Drives", 0 + 32

Else

'''' Place Another Here for if it there

Act.Popup "It Was There In This Location" & vbCrLf & strD & "\TestMe.txt", 3, "Confirm", 0 + 32

Exit For

End If

End If

Next

These VBS scripts use the If not Exists statement to check for the file

Tested the script and it works 100% on my computer.

Hope this helps.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

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