From: Eric on
Hi,

I have a script that use WMI to stop and delete service which works fine and
then it should delete all files that contains %vnc% in the filename and for
which the extension is EXE.

It is working fine if the remote computer is a WinXP but if remote is Win2K,
it does not work.

What is wrong??

Here is my function delete.

Function del_VNC_exe(strPC)
Dim objWMIService, colFiles, objFile

Set objWMIService = GetObject("winmgmts:\\" & strPC & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where
Drive='C:' AND FileName LIKE '%vnc%' And Extension = 'exe'")
WScript.Echo colFiles.Count & " files were found." 'for testing
For Each objFile In colFiles
Wscript.Echo objFile.Name 'for testing
'objFile.delete
Next
End Function

--
Thank you
Eric :)
From: Richard Mueller [MVP] on
Eric wrote:

> I have a script that use WMI to stop and delete service which works fine
> and
> then it should delete all files that contains %vnc% in the filename and
> for
> which the extension is EXE.
>
> It is working fine if the remote computer is a WinXP but if remote is
> Win2K,
> it does not work.
>
> What is wrong??
>
> Here is my function delete.
>
> Function del_VNC_exe(strPC)
> Dim objWMIService, colFiles, objFile
>
> Set objWMIService = GetObject("winmgmts:\\" & strPC & "\root\cimv2")
> Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where
> Drive='C:' AND FileName LIKE '%vnc%' And Extension = 'exe'")
> WScript.Echo colFiles.Count & " files were found." 'for testing
> For Each objFile In colFiles
> Wscript.Echo objFile.Name 'for testing
> 'objFile.delete
> Next
> End Function
>
> --

The LIKE operator is not available in Windows 2000.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


From: Eric on
Ok! So how can I fix that? is there a way to do the same thing for computer
that are in Win2K?
--
Thank you
Eric :)


"Richard Mueller [MVP]" wrote:

> Eric wrote:
>
> > I have a script that use WMI to stop and delete service which works fine
> > and
> > then it should delete all files that contains %vnc% in the filename and
> > for
> > which the extension is EXE.
> >
> > It is working fine if the remote computer is a WinXP but if remote is
> > Win2K,
> > it does not work.
> >
> > What is wrong??
> >
> > Here is my function delete.
> >
> > Function del_VNC_exe(strPC)
> > Dim objWMIService, colFiles, objFile
> >
> > Set objWMIService = GetObject("winmgmts:\\" & strPC & "\root\cimv2")
> > Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where
> > Drive='C:' AND FileName LIKE '%vnc%' And Extension = 'exe'")
> > WScript.Echo colFiles.Count & " files were found." 'for testing
> > For Each objFile In colFiles
> > Wscript.Echo objFile.Name 'for testing
> > 'objFile.delete
> > Next
> > End Function
> >
> > --
>
> The LIKE operator is not available in Windows 2000.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
From: Richard Mueller [MVP] on
I don't think there is a good solution. You will need to retrieve all files
with the given extension, then in the loop where you enumerate the resulting
collection you can parse the file names with VBScript functions, like InStr.
It would help to restrict the results to a specific path, if that is
possible.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Eric" <Eric(a)discussions.microsoft.com> wrote in message
news:3B5A252F-08CE-4DBC-8EDA-0A7267E6B9E8(a)microsoft.com...
> Ok! So how can I fix that? is there a way to do the same thing for
> computer
> that are in Win2K?
> --
> Thank you
> Eric :)
>
>
> "Richard Mueller [MVP]" wrote:
>
>> Eric wrote:
>>
>> > I have a script that use WMI to stop and delete service which works
>> > fine
>> > and
>> > then it should delete all files that contains %vnc% in the filename and
>> > for
>> > which the extension is EXE.
>> >
>> > It is working fine if the remote computer is a WinXP but if remote is
>> > Win2K,
>> > it does not work.
>> >
>> > What is wrong??
>> >
>> > Here is my function delete.
>> >
>> > Function del_VNC_exe(strPC)
>> > Dim objWMIService, colFiles, objFile
>> >
>> > Set objWMIService = GetObject("winmgmts:\\" & strPC & "\root\cimv2")
>> > Set colFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile
>> > Where
>> > Drive='C:' AND FileName LIKE '%vnc%' And Extension = 'exe'")
>> > WScript.Echo colFiles.Count & " files were found." 'for testing
>> > For Each objFile In colFiles
>> > Wscript.Echo objFile.Name 'for testing
>> > 'objFile.delete
>> > Next
>> > End Function
>> >
>> > --
>>
>> The LIKE operator is not available in Windows 2000.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>>
>>