![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 > > -- -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||