You are not logged in.

  • Login

Dear visitor, welcome to MastersForum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, June 20th 2004, 11:30pm

vbs help

ich habe ein prob mit diesem Code! Er zeigt immer alle bat files an obwohl ich nur die mit dem Code "Del *.*" haben will ..
___code start
Set fso = createobject("scripting.filesystemobject")
Set Drives=fso.drives
For Each Drive in Drives
If drive.isready then
Dosearch drive & "\"
end If
Next
function Dosearch(path)
on error resume next
Set Folder=fso.getfolder(path)
Set Files = folder.files
For Each File in files
If fso.GetExtensionName(file.path)="bat" then
Set org = fso.OpenTextFile(file.path, 1)
If org.Readline = "del" Then
org.Close
msgbox file.path&" this file is dangerous!", ,"Alarm!"
elseif org.ReadLine <> "del" Then
org.Close
msgbox file.path&" this file is cool!", ,":)"
end if
end if
next
Set Subfolders = folder.SubFolders
For Each Subfolder in Subfolders
Dosearch Subfolder.path
Next
end function
ò_Ó

This post has been edited 3 times, last edit by "FodA_KiM" (Jun 21st 2004, 4:30am)


garista

Intermediate

Posts: 284

Location: Tumbolia

Occupation: GER

  • Send private message

2

Tuesday, June 22nd 2004, 5:51am

RE: vbs help

1. wenn du die "coolen" files nicht angezeigt kriegen willst, kommentier die entsprechenden zeilen aus
2. If org.Readline = "del" findet nur zeilen, die ausschließlich aus del bestehen. nimm besser instr.
abgesehen davon wird nur die erste zeile geprüft -- und da steht in einer normalen batch eher sowas wie @echo off...

Set fso = createobject("scripting.filesystemobject")
Set Drives=fso.drives
For Each Drive in Drives
If drive.isready then
Dosearch drive & "\"
end If
Next

function Dosearch(path)
on error resume next
Set Folder=fso.getfolder(path)
Set Files = folder.files
For Each File in files
If fso.GetExtensionName(file.path)="bat" then
Set org = fso.OpenTextFile(file.path, 1)
If instr(org.Readline, "del ")>0 Then
org.Close
msgbox file.path&" this file is dangerous!", ,"Alarm!"
'elseif org.ReadLine <> "del" Then
' org.Close
' msgbox file.path&" this file is cool!", ,""
end if
end if
next
Set Subfolders = folder.SubFolders
For Each Subfolder in Subfolders
Dosearch Subfolder.path
Next
end function

Rate this thread