Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Delete file on remote computer

1 réponse
Avatar
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 & "\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 :)

1 réponse

Avatar
Gilles LAURENT [MVP]
"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
<http://www.microsoft.com/technet/scriptcenter/topics/win2003/like.mspx>

--
Gilles LAURENT
MVP Windows Server - Admin Frameworks
http://glsft.free.fr