First, thanks for such a reliable fource for information previously, this forum has been a big help. Now I'm finally registering and have an issue that I've been unable to solve on my own.

I have an MSI I will be deploying very shortly. Within this MSI I have a VB script that is not working when the MSI is executed in silent or passive mode (a must for deployment). When launching in the standard mode, given an interactive UI, everything works fine. Below is the script containing three 'simple' steps.
  1. Kill process 'MDTAppPortal'
    1. This portion executes with no problem
  2. Checks to ensure MDTAppPortal.exe has stopped running before continuing
    1. Again, as far as I can tell anyway, there are no problems executing
  3. Uninstalls previous version of the application
    1. This portion simply does not execute if run quiet/passive
    2. no issues when run normal mode
    3. no issues when run as a .vbs external of the MSI
Can anyone give me insight as to why this isn't working and what can be done to correct it?

Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'MDTAppPortal.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()

Next

WaitForProcess ".", "MDTAppPortal.exe"
Sub WaitForProcess(strComputer, strProcess)
Dim wmiQuery : wmiQuery = "Select * From Win32_Process Where Name='" _
& strProcess & "'"
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer _
& "\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery(wmiQuery)

Dim intProcCount : intProcCount = colItems.Count
Do While intProcCount > 0
Set colItems = objWMIService.ExecQuery(wmiQuery)
intProcCount = colItems.Count
WScript.Sleep 1000
Loop
End Sub

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'MDT Application Portal'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I am not clear on why you are using a vbscript to remove an application within your MSI. If it an MSI installation, use the upgrade table. If not, try custom actions to remove the registry entries and files associated with the old app.

Also, you may be having problems with WScript as this is not supported (IIRC) within embedded vbscripts.

Using a vbscript to kill the app process is cool, but not to remove an application.
Answered 12/12/2007 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
That makes two of us that are 'not clear' on this.

in short, the team responsible for the packaging of this product has not provided a very solid MSI and this is the work around until they can give me a 'good' version.

I had seen issues noted with wscript....but with the execution of that portion of the script i cant see why that would be the issue. both the uninstall and the kill process pull from the WMIService...

am i missing something
Answered 12/12/2007 by: JLMILLER
Yellow Belt

Please log in to comment
0
Jeremy,

It seems like the packagers don't have a solid understanding of MSI technology. The answer really depends on whether the old package is an MSI or not. If it was not, some sort of custom action may need to be called to remove it. If it is, the upgrade talble should be used.
If you are going to use a script to remove the previous app better to use the ProductCode (IdentifyingNumber in the WMI collection Win32_Product) instead of name, since the name can sometimes be changed by the user or installer.

Good luck
Answered 12/12/2007 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
By all means use the script to kill the process: that's pretty standard fare. What needs clarification is "I have a VB script that is not working". You couldn't be more vague? :)

Put some error-trapping in the script (either MsgBox if running interactively, or use the Session.Installer.CreateRecord method to write to the Installer log), log the installation and then let us know what's "not working."
Answered 12/13/2007 by: VBScab
Red Belt

Please log in to comment
0
Sorry if I was clear enough in my problem description. It appears what I've been running into is the limitations of Windows Installer w/ certain scripting commands.

After attempting several methods to compile everything I need into the MSI, I've taken the path of an external VBS that automates my steps. I'm losing some of the benefits of deploying the MSI vs a VBS, but it will go as a workaround until they can correct the issues/limitations of their MSI.


thank you for hte input
Answered 12/13/2007 by: JLMILLER
Yellow Belt

Please log in to comment
0
It appears what I've been running into is the limitations of Windows Installer w/ certain scripting commands.The only limitation I'm aware of (and I've written a fair few scripts - none of them trivial - in my time) is that, for embedded scripts, you can't use the WScript directive, as that refers to Windows Script Host and Windows Installer uses its own host. There's also a size limit (which I routinely exceed) which in some future WI version MS might decide to enforce.

What specifically was the problem?
Answered 12/13/2007 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity