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 & "oot\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 :)
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 & "oot\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 :)

Poser une question


[...]
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