Forum Discussion
Hi Audrey,
Please try using the script from Allen's (May 11, 2011) or Du Tran's posts (this is the same script in different languages) in the thread Alexei mentioned and let me know your results.- pjaudreyOccasional ContributorHi David,
Yes I had tried that below code which is posted from Du Tran and I am getting error:-
If Not p.Exists Then
Call Log.Error("The 'Add or remove programs' dialog was not found")
Sub SelectApplicationFromControlPanel()
Dim WshShell, oExec, p, w, applicationWnd
Dim button, applicationName, buttonName, programsList
applicationName = "APPLICATION_NAME"
buttonName = "Uninstall*"
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("RunDll32.exe shell32.dll,"&_
"Control_RunDLL appwiz.cpl,,0")
BuiltIn.Delay(10000)
Sys.Process("Explorer").Refresh()
Set p = Sys.Process("Explorer").FindChild("WndCaption", "Control Panel\Programs\Programs and Features")
If Not p.Exists Then
Call Log.Error("The 'Add or remove programs' dialog was not found")
Else
Set programsList = p.FindChild("WndClass", "SysListView32", 20)
Log.Message(p.FullName)
Call programsList.ClickItem(applicationName, 0)
Dim propArray(1)
propArray(0) = "Caption"
propArray(1) = "ObjectType"
Dim valuesArray(1)
valuesArray(0) = buttonName
valuesArray(1) = "Button"
Set button = p.FindChild(propArray, valuesArray, 20)
Call button.Click()
'Insert Uninstall Code Here
p.Close()
End If
End Sub
Audrey
Hi Audrey,
Modify the line:
Set p = Sys.Process("Explorer").FindChild("WndCaption", "Control Panel\Programs\Programs and Features")
in the following way:
Set p = Sys.Process("Explorer", 2).FindChild("WndCaption", "Programs and Features")- pjaudreyOccasional Contributor
Hi Audrey,
It seems you are using the How To script. You need to make corrections to the script you posted, not the original one. Try using the following script:
Sub SelectApplicationFromControlPanel()
Dim WshShell, oExec, p, w, applicationWnd
Dim button, applicationName, buttonName, programsList
applicationName = "APPLICATION_NAME"
buttonName = "Uninstall*"
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("RunDll32.exe shell32.dll,"&_
"Control_RunDLL appwiz.cpl,,0")
BuiltIn.Delay(10000)
Sys.Process("Explorer").Refresh()
Set p = Sys.Process("Explorer", 2).FindChild("WndCaption", "Programs and Features")
If Not p.Exists Then
Call Log.Error("The 'Add or remove programs' dialog was not found")
Else
Set programsList = p.FindChild("WndClass", "SysListView32", 20)
Log.Message(p.FullName)
Call programsList.ClickItem(applicationName, 0)
Dim propArray(1)
propArray(0) = "Caption"
propArray(1) = "ObjectType"
Dim valuesArray(1)
valuesArray(0) = buttonName
valuesArray(1) = "Button"
Set button = p.FindChild(propArray, valuesArray, 20)
Call button.Click()
'Insert Uninstall Code Here
p.Close()
End If
End Sub
Does this help?- pjaudreyOccasional ContributorHi David,
1. Yes, the scripts that you give trigger the Unistall process. So now I will have to code the rest of the unistall code.
2. Just a query, the script that you provide is able to handle different type of Windows OS like Windows Server 2003, XP, Vista, Windows 7 with 32 bits and 64 bits? Or there should be handle different by different script for unistall and install?
Regards,
Audrey NG
Hi Audrey,
The script is meant to be used on Windows 7. However, it is possible that it can be run on other operating systems. One should take into consideration that the needed window can have different names ("Add or remove programs" or "Programs and Features") and be the child of the first or second instance of Explorer.
Related Content
- 3 years ago
- 6 months ago
Recent Discussions
- 3 hours ago
- 2 days ago
- 2 days ago