Delete file on remote computer

Le
Eric
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 & "ootcimv2")
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 :)
Vidéos High-Tech et Jeu Vidéo
Téléchargements
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Gilles LAURENT [MVP]
Le #16408411
"Eric" wrote:

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



[...]

It's because the LIKE operator is not available on Windows 2000 :-(
It's an addition to WQL since Windows XP/2003

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr
Publicité
Poster une réponse
Anonyme