scott_humphris
can anyone help me with a script that will delete two files at once from specified paths?
----------------------------
#2 03 Sep 2010 10:10
Simon Sheppard
Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile ("C:\docs\test1.txt")
objFSO.DeleteFile ("C:\docs\test2.txt")
https://ss64.com/vb/filesystemobject.html
and heres a complete script for cleaning out files from a Roaming Profile:
https://ss64.com/vb/syntax-profile.html
----------------------------
#3 03 Sep 2010 11:11
scott_humphris
Thanks very much simon.
Also i am using this script to kill a process:
Code: Select all
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()
Thanks for your help.
----------------------------
#4 03 Sep 2010 11:27
Simon Sheppard
Just change the Select statement:
Code: Select all
SELECT * FROM Win32_Process WHERE Name = 'outlook.exe' or Name = 'Somethingelse.exe'
#5 09 Jan 2011 17:06
arash
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
----------------------------
#6 05 Nov 2014 02:41
bars143
hi im newbie here,scott_humphris wrote:
Thanks very much simon.
Also i am using this script to kill a process:
How can i get it to kill more than one process.Code: Select all
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()
Thanks for your help.
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
----------------------------
#7 05 Nov 2014 09:56
Simon Sheppard
Echo
https://ss64.com/vb/echo.html
----------------------------
#8 05 Nov 2014 15:25
bars143
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.Code: Select all
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
hi ! Simon Sheppard,
can you help me find a website link that provide a complete list of error code?
original thread: https://ss64.org/oldforum/viewtopic.php?id=1082