You are not logged in.
Pages: 1
can anyone help me with a script that will delete two files at once from specified paths?
Offline
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile ("C:\docs\test1.txt")
objFSO.DeleteFile ("C:\docs\test2.txt")
see here for more options
http://ss64.com/vb/filesystemobject.html
and heres a complete script for cleaning out files from a Roaming Profile:
http://ss64.com/vb/syntax-profile.html
Offline
Thanks very much simon.
Also i am using this script to kill a process:
Const strComputer = "."
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
How can i get it to kill more than one process.
Thanks for your help.
Offline
Just change the Select statement:
SELECT * FROM Win32_Process WHERE Name = 'outlook.exe' or Name = 'Somethingelse.exe'
Offline
Dear Simon is there a better way to terminate several processes?
I mean in case of many processes to kill, it is a bit disorientating to add all processes name in the middle of the code.
I am wondering if it is possible to enter all processes name at the top of the code as parameters and then the vbscript do the rest.
thanks
Offline
Thanks very much simon.
Also i am using this script to kill a process:
Const strComputer = "."
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()How can i get it to kill more than one process.
Thanks for your help.
hi im newbie here,
its my first post and just ask of above script of what code to be added that popup message that outlook.exe is stopped.
i know a batch script equivalent is "echo".
thanks,
Bars
Offline
Offline
option explicit
Const strComputer = "."
Dim objWMIService, colProcessList, objProcess
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'cmd.exe'")
If colProcessList.Count > 0 Then
On Error Resume next
For Each objProcess in colProcessList
objProcess.Terminate()
WScript.Echo "Process terminated: cmd.exe"
Next
On Error goTo 0
Else
WScript.Echo "Process not found: cmd.exe"
End If
thank i made it work. i had it done many hours trying to use "WScript.Echo" with batch-like "if-else" command. but its error messages are too many and afterward it always help faster due to its description of error which i google it error code all the time.
hi ! Simon Sheppard,
can you help me find a website link that provide a complete list of error code?
Offline
Pages: 1