Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Delete files on remote computer

Reply
 
Old 07-24-2008   #1 (permalink)
Eric


 
 

Delete files on remote computer

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

My System SpecsSystem Spec
Old 07-24-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Delete files on remote computer

Eric wrote:
Quote:

> 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
--


My System SpecsSystem Spec
Old 07-24-2008   #3 (permalink)
Eric


 
 

Re: Delete files on remote computer

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:
Quote:

> Eric wrote:
>
Quote:

> > 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
> --
>
>
>
My System SpecsSystem Spec
Old 07-24-2008   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: Delete files on remote computer

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@xxxxxx> wrote in message
news:3B5A252F-08CE-4DBC-8EDA-0A7267E6B9E8@xxxxxx
Quote:

> 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:
>
Quote:

>> Eric wrote:
>>
Quote:

>> > 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
>> --
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Remote desktop can not find remote computer Network & Sharing
Easy transfer...will it delete files from old computer? Vista installation & setup
Vista: This Computer can't connect to the Remote Computer Vista networking & sharing
Computer Management: Can't connect to a remote computer Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46