title: kill the Excel.exe from the .vbs file
body: <p>Suppose I am running an .vbs script to work with Excel sheet,now if somehow due to any reason any error occurs,I want to quit that .vbs script to run and besides to kill the process EXCEL.EXE from that .vbs file immedaitely.</p>
  
  <p>After killing that process EXCEL.EXE, i want all the data change has been made by the script on the excel sheet should need to be <strong><em>ROLLBACK</em></strong></p>
  
  <p>Is it possible?</p>
  
  <p><strong><em>UPDATE:</em></strong></p>
  
  <p>I have a code with me, but how should I embed it with my script,I couldn't understand:</p>
  
  <pre><code> Option Explicit
   Dim objService,Process
   set objService = getobject("winmgmts:")
  
   for each Process in objService.InstancesOf("Win32_process")
    WScript.echo Process.Name &amp; vbTab &amp; Process.processid
   Next
  </code></pre>
  
  <p><strong><em>SCRIPT</em></strong></p>
  
  <pre><code>  Option Explicit
  
  
  
    Set objExcel1 = CreateObject("Excel.Application")'Object for Condition Dump
  
    strPathExcel1 = "D:\VB\Copy of Original Scripts\CopyofGEWingtoWing_latest_dump_21112012.xls"
    objExcel1.Workbooks.open strPathExcel1
    Set objSheet1 = objExcel1.ActiveWorkbook.Worksheets(1)
    Set objSheet2 = objExcel1.ActiveWorkbook.Worksheets("Bad Data")
  
   objExcel1.ScreenUpdating = False
   objExcel1.Calculation = -4135  'xlCalculationManual
  
   IntRow2=2
   IntRow1=4
    Do Until IntRow1 &gt; objSheet1.UsedRange.Rows.Count
  
    ColStart = objExcel1.Application.WorksheetFunction.Match("Parent Business Process ID", objSheet1.Rows(3), 0) + 1 
  
  Do Until ColStart &gt; objSheet1.UsedRange.Columns.Count And objSheet1.Cells(IntRow1,ColStart) = ""
  
      If objSheet1.Cells(IntRow1,ColStart + 1) &gt; objSheet1.Cells(IntRow1,ColStart + 5) And objSheet1.Cells(IntRow1,ColStart + 5) &lt;&gt; "" Then
  
      objSheet1.Range(objSheet1.Cells(IntRow1,1),objSheet1.Cells(IntRow1,objSheet1.UsedRange.Columns.Count)).Copy
      objSheet2.Range(objSheet2.Cells(IntRow2,1),objSheet2.Cells(IntRow2,objSheet1.UsedRange.Columns.Count)).PasteSpecial
      IntRow2=IntRow2+1
      Exit Do
  
      End If
  
  ColStart=ColStart+4
  Loop
  
  IntRow1=IntRow1+1
  Loop
  
  objExcel1.ScreenUpdating = True
  objExcel1.Calculation = -4105   'xlCalculationAutomatic
  
  '=======================
  objExcel1.ActiveWorkbook.SaveAs strPathExcel1
  objExcel1.Workbooks.close
  objExcel1.Application.Quit
  </code></pre>
  
  <p>'======================</p>
  
  <p><strong><em>TerminateCode</em></strong></p>
  
  <pre><code>   strComputer = "FullComputerName" 
     strDomain = "DOMAIN" 
     strUser = InputBox("Enter user name") 
     strPassword = InputBox("Enter password") 
     Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
     Set objWMIService = objSWbemLocator.ConnectServer(strComputer, _ 
     "root\CIMV2", _ 
     strUser, _ 
     strPassword, _ 
     "MS_409", _ 
     "ntlmdomain:" + strDomain) 
     Set colProcessList = objWMIService.ExecQuery _
     ("SELECT * FROM Win32_Process WHERE Name = 'notepad.exe'")
   For Each objProcess in colProcessList
    objProcess.Terminate()
   Next
  </code></pre>
  
  <p>thanks,</p>