0

I have a task in which whenever an application is running, and when I run upgrade of that application then the application should be removed from processes else it will throw licenses error as some of the licenses are attached to that application process. Now I have created VB Script code to kill that particular application process and it is working fine in my local environment in windows 7. But when I try to run same code on QA environment in windows 7 then process is not killing anyhow. I tried many things like killing using administrator rights,created logs but not getting any hint where I am missing out.

Currently I am not having code if someone wants to check the VB Script code then I am updating the question after sometime.

If anyone have any information regarding this please suggest me...

Thanks in advance.

Refer below code:

Option Explicit

DIM FileObject

On Error Resume Next

set FileObject = CreateObject( "WScript.Shell" )

FileObject.Run "TaskKill /F /IM Program1.exe", , True

FileObject.Run "TaskKill /F /IM Program2.exe", , True

FileObject.Run "TaskKill /F /IM Program3.exe", , True

FileObject.Run "TaskKill /F /IM Program4.exe", , True

FileObject.Run "TaskKill /F /IM Program5.exe", , True

FileObject.Run "TaskKill /F /IM Program6.exe", ,True

In above code, Program1 and Program6 are closed successfully from task manager but not other programs.

Note:- Above code is working fine when I explicitly running vb script file but when I include that script code in my upgrader exe then it is killing only program1 and program6.

Dhiren
  • 153
  • 1
  • 13

1 Answers1

0

The issue may be because of 32 and 64 bit Processes.Try to handle it use Win32_Process

or you can try using a taskkill

eg

Dim myshell : myshell = CreateObject("WScript.Shell")

    ' Launch notepad '
    myshell.Run "notepad"
    WScript.Sleep 3000

    ' Kill notepad '
    myshell.Run("taskkill /im notepad.exe", , True)

or

 Dim myshell : Set myshell = CreateObject("WScript.Shell")
Set Rt = myshell.Exec("Notepad") : wscript.sleep 4000 : Rt.Terminate

Not sure whether you are trying this as sample code is not provided

Sreenath Ganga
  • 696
  • 4
  • 19
  • 48