Is there any way to define wild characters to search for the file like
"*paypal*.txt or just *paypal* to look for files like paypal2.exe or
paypal.word (Any file or extension with paypal in it). Below is the
code I used to search with exact name

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strComputer = "."
strFilename = "paypal" ' without extension
strExtension = "txt" ' file extension - use lowercase

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select name, extension from
CIM_Datafile where Filename = '"&strFilename&"'")
For Each objFile in colFiles
If objFile.Extension = strExtension then
Wscript.Echo objFile.Name
'nRet = objFSO.DeleteFile(objFile.Name,True)
End If
Next
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Re: Find Files by Christoph

Christoph
Tue Sep 14 05:15:25 CDT 2004

14.09.2004 01:24, Kumar schrieb:

> Is there any way to define wild characters to search for the file like
> "*paypal*.txt or just *paypal* to look for files like paypal2.exe or
> paypal.word (Any file or extension with paypal in it). Below is the
> code I used to search with exact name

your looking for the LIKE-Operator (available for Win XP/2003 or higher)

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strComputer = "."
strFilename = "paypal" ' without extension
strExtension = "txt" ' file extension - use lowercase

Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set files = wmi.ExecQuery ("Select name from CIM_Datafile where " _
"Filename LIKE '%" & strFilename & "%' " _
"AND Extension = '" & strExtension & "'")
for each file in files
Wscript.Echo file.Name
nRet = file.Delete(objFile.Name,True) ' 0 = success
if nRet <>0 then _
msgbox "Error " & nRet & " tyring to delete " & file.name
Next
> '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


--
Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979

Re: Find Files by Christoph

Christoph
Tue Sep 14 05:18:12 CDT 2004

14.09.2004 12:15, Christoph Basedau schrieb:

> 14.09.2004 01:24, Kumar schrieb:

> for each file in files
> Wscript.Echo file.Name
> nRet = file.Delete(objFile.Name,True) ' 0 = success

should read:
nRet = file.Delete() ' 0 = success
'..
next


--
Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979

Re: Find Files by sainicaus

sainicaus
Wed Sep 15 11:04:48 CDT 2004

I am getting error, Please help!!!!!

<<C:\cscript findfile.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Documents and Settings\Administrator\Desktop\findfile.vbs(7, 67) Microsoft VB
Script compilation error: Expected ')'

C:\>





Christoph Basedau <e_tonne@hotmail.com> wrote in message news:<4146c4c5$0$26107$9b4e6d93@newsread4.arcor-online.net>...
> 14.09.2004 01:24, Kumar schrieb:
>
> > Is there any way to define wild characters to search for the file like
> > "*paypal*.txt or just *paypal* to look for files like paypal2.exe or
> > paypal.word (Any file or extension with paypal in it). Below is the
> > code I used to search with exact name
>
> your looking for the LIKE-Operator (available for Win XP/2003 or higher)
>
> '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> strComputer = "."
> strFilename = "paypal" ' without extension
> strExtension = "txt" ' file extension - use lowercase
>
> Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
> Set files = wmi.ExecQuery ("Select name from CIM_Datafile where " _
> "Filename LIKE '%" & strFilename & "%' " _
> "AND Extension = '" & strExtension & "'")
> for each file in files
> Wscript.Echo file.Name
> nRet = file.Delete(objFile.Name,True) ' 0 = success
> if nRet <>0 then _
> msgbox "Error " & nRet & " tyring to delete " & file.name
> Next
> > '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Re: Find Files by Christoph

Christoph
Wed Sep 15 11:51:13 CDT 2004

15.09.2004 18:04, Kumar schrieb:
> I am getting error, Please help!!!!!
>
> <<C:\cscript findfile.vbs
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
> C:\Documents and Settings\Administrator\Desktop\findfile.vbs(7, 67) Microsoft VB
> Script compilation error: Expected ')'

There were two ampersands missing in line 7, try this code (w/o linenumbers)

>> '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#1 strComputer = "."
#2 strFilename = "paypal" ' without extension
#3 strExtension = "txt" ' file extension - use lowercase
#4
#5 Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
#6 & strComputer & "\root\cimv2")
#7 Set files = wmi.ExecQuery ("Select name from CIM_Datafile where " _
#8 & "Filename LIKE '%" & strFilename & "%' " _
#9 & "AND Extension = '" & strExtension & "'")
#10 For each file in files
#11 Wscript.Echo file.Name
#12 nRet = file.Delete() ' 0 = success
#13 if nRet <>0 then _
#14 msgbox "Error " & nRet & " tyring to delete " & file.name
#15 Next
>> > '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

--
Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979

Re: Find Files by sainicaus

sainicaus
Thu Sep 16 15:03:12 CDT 2004

Thanks for reply, One last question or fix Please!!

When I try to run the below listed code on the remote machine, I get a
error file.vbs(11,2) (null):0x80041017 but works fine locally.

The original script in my first post works fine on the remote machine.
Is there any way to change the below listed code to run on the remote
machine

Thanks!
Kumar

Christoph Basedau <e_tonne@hotmail.com> wrote in message news:<4148730e$0$18568$9b4e6d93@newsread2.arcor-online.net>...
> 15.09.2004 18:04, Kumar schrieb:
> > I am getting error, Please help!!!!!
> >
> > <<C:\cscript findfile.vbs
> > Microsoft (R) Windows Script Host Version 5.6
> > Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
> >
> > C:\Documents and Settings\Administrator\Desktop\findfile.vbs(7, 67) Microsoft VB
> > Script compilation error: Expected ')'
>
> There were two ampersands missing in line 7, try this code (w/o linenumbers)
>
> >> '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> #1 strComputer = "."
> #2 strFilename = "paypal" ' without extension
> #3 strExtension = "txt" ' file extension - use lowercase
> #4
> #5 Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
> #6 & strComputer & "\root\cimv2")
> #7 Set files = wmi.ExecQuery ("Select name from CIM_Datafile where " _
> #8 & "Filename LIKE '%" & strFilename & "%' " _
> #9 & "AND Extension = '" & strExtension & "'")
> #10 For each file in files
> #11 Wscript.Echo file.Name
> #12 nRet = file.Delete() ' 0 = success
> #13 if nRet <>0 then _
> #14 msgbox "Error " & nRet & " tyring to delete " & file.name
> #15 Next
> >> > '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Re: Find Files by Torgeir

Torgeir
Thu Sep 16 18:02:24 CDT 2004

Kumar wrote:

> Thanks for reply, One last question or fix Please!!
>
> When I try to run the below listed code on the remote machine, I get a
> error file.vbs(11,2) (null):0x80041017 but works fine locally.
>
> The original script in my first post works fine on the remote machine.
> Is there any way to change the below listed code to run on the remote
> machine
Hi

Sorry, CIM_DataFile doesn't support UNC (it might work if you
map a drive letter to the remote computers admin share first and
use that one instead) ...



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Find Files by sainicaus

sainicaus
Fri Sep 17 13:14:16 CDT 2004

I am using CIM_DataFile for both the scripts below and one work and
other one dosen't::

Scripts Works on remote computer
***********************************************************************
strComputer = "192.168.1.105"
strFilename = "paypal" ' without extension
strExtension = "txt" ' file extension - use lowercase

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select name, extension from
CIM_Datafile where Filename = '"&strfilename&"'")
For Each objFile in colFiles
If objFile.Extension = strExtension then
Wscript.Echo objFile.Name
'nRet = objFSO.DeleteFile(objFile.Name,True)
End If
Next
************************************************************************

Scripts that dosen't Works on remote computer
************************************************************************
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strComputer = "192.168.1.105"
strFilename = "india" ' without extension
strExtension = "txt" ' file extension - use lowercase

Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set files = wmi.ExecQuery ("Select name from CIM_Datafile where " _
& "Filename LIKE '%" & strFilename & "%' " _
& "AND Extension = '" & strExtension & "'")
For each file in files
Wscript.Echo file.Name
' nRet = file.Delete() ' 0 = success
if nRet <>0 then _
msgbox "Error " & nRet & " tyring to delete " & file.name
Next
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



"Torgeir Bakken \(MVP\)" <Torgeir.Bakken-spam@hydro.com> wrote in message news:<#2VPSFEnEHA.2864@tk2msftngp13.phx.gbl>...
> Kumar wrote:
>
> > Thanks for reply, One last question or fix Please!!
> >
> > When I try to run the below listed code on the remote machine, I get a
> > error file.vbs(11,2) (null):0x80041017 but works fine locally.
> >
> > The original script in my first post works fine on the remote machine.
> > Is there any way to change the below listed code to run on the remote
> > machine
> Hi
>
> Sorry, CIM_DataFile doesn't support UNC (it might work if you
> map a drive letter to the remote computers admin share first and
> use that one instead) ...

Re: Find Files by Christoph

Christoph
Fri Sep 17 16:03:13 CDT 2004

16.09.2004 22:03, Kumar schrieb:

> Thanks for reply, One last question or fix Please!!
>
> When I try to run the below listed code on the remote machine, I get a
> error file.vbs(11,2) (null):0x80041017 but works fine locally.
>
> The original script in my first post works fine on the remote machine.
> Is there any way to change the below listed code to run on the remote
> machine
>

Sorry, i'm not in too deep into WMI-Remoting.
What versions of Windows do you have on the remote machines?

> Thanks!

--
Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979