How do you search for a file and SET the location as a variable in VBS?
For instance CMD:
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:\WhateverFolder\WhateverFile.txt SET WhateverLoc=%%I:\WhateverFolder
Posted 29 November 2006 - 12:09 PM
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:\WhateverFolder\WhateverFile.txt SET WhateverLoc=%%I:\WhateverFolder
Posted 29 November 2006 - 04:34 PM
MioKawaii, on Nov 29 2006, 07:09 PM, said:
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:\WhateverFolder\WhateverFile.txt SET WhateverLoc=%%I:\WhateverFolder
Quote
Const Removable = 1, Fixed = 2, CD_DVD = 4
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ChkFolder, Drv, StrD
Set Drv = Fso.Drives
For Each StrD In Drv
If StrD.DriveType = Fixed Then
If Fso.FolderExists(StrD & "\Windows\System32") Then
Act.Popup "Found The System32 Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Only Found Instance Of Windows\System32 As The New Varible
ChkFolder = StrD & "\Windows\System32"
Exit For
End If
End If
Next
Quote
Const Removable = 1, Fixed = 2, CD_DVD = 4
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ChkFolder, Drv, StrD
Set Drv = Fso.Drives
For Each StrD In Drv
If StrD.DriveType = Fixed Then
If Fso.FolderExists(StrD & "\Windows\System32") Then
Act.Popup "Found The System32 Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Last Found Instance Of Windows\System32 As The New Varible
ChkFolder = StrD & "\Windows\System32"
End If
End If
Next
Quote
Const Removable = 1, Fixed = 2, CD_DVD = 4
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ChkFile, Drv, StrD
Set Drv = Fso.Drives
For Each StrD In Drv
If StrD.DriveType = Fixed Then
If Fso.FileExists(StrD & "\Windows\System32\Shell32.dll") Then
Act.Popup "Found The Shell32.dll Folder On " & StrD ,5,"Confirm",4128
'/-> Set The First Found Instance Of Windows\System32\Shell32.dll As The New Varible
ChkFile = StrD & "\Windows\System32"
Exit For
End If
End If
Next
Quote
Const Removable = 1, Fixed = 2, CD_DVD = 4
Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim ChkFile, Drv, StrD
Set Drv = Fso.Drives
For Each StrD In Drv
If StrD.DriveType = Fixed Then
If Fso.FileExists(StrD & "\Windows\System32\Shell32.dll") Then
Act.Popup "Found The Shell32.dll Folder On " & StrD ,5,"Confirm",4128
'/-> Set The Last Found Instance Of Windows\System32\Shell32.dll As The New Varible
ChkFile = StrD & "\Windows\System32"
End If
End If
Next