View Full Version : Loop through folder to unregister ActiveX controls
strager
08-08-2009, 09:02 PM
Hi,
I have an app that doesn't uninstall activex controls in a folder.
In my setup, I need to check if that folder exists and if it does, I need to unregister every ActiveX control in that folder.
Then I need to delete the folder and it's contents.
I found how to check for a folder and your sample on unregister activex controls. I just can't figure out how to loop through all the controls when I don't know how many there are.
bresult = Folder.DoesExist("%CommonFilesFolder%\SMS");
if bresult then
Loop through folder and unregister all activex controls in folder
When all controls have been unregistered...
Delete folder and contents.
end
Thanks for your help,
Sheri
strager
08-08-2009, 11:30 PM
I have tried to put something together... Is this correct?
bresult = Folder.DoesExist(SessionVar.Expand("%CommonFilesFolder%\SMS"));
if bresult then
-- A while loop
while File.Find(SessionVar.Expand("%CommonFilesFolder%\SMS"), "*.ocx", false, false, nil, nil) do
-- Do something here\
sPath =SessionVar.Expand("%CommonFilesFolder%\SMS")
sFolder = String.SplitPath("sPath");
sFile = sFolder.Filename;
sExt = sFolder.Extension;
-- get and set name of control
tFind = File.Find("C:\\", "sName", true, false, nil);
iCount = tFind.Count
-- check to see if another instance of the file exists. If it does, don't unregister or delete.
if iCount <= 1 then
System.UnregisterActiveX("sPath" .. "\\sName");
File.Delete("sFolder".."\\sName", false, false, false, nil);
end
end
Folder.Delete(SessionVar.Expand("%CommonFilesFolder%\SMS"));
end
Thanks
strager
08-10-2009, 12:22 PM
I have a customer that has installed an application of mine and one of the packages installs an activex that causes an out of memory error.
I couldn't figure out what control is causing the problem but it is one that is in a specific folder.
I unregistered and deleted all controls in a test machine and then installed again with a new setup and I no longer get the error.
What I need to do, is create a setup that will unregister and delete all the controls in that folder, so I can do a fresh install.
Please help... it is urgent! Thank you
I have tried to put something together... Is this correct?
bresult = Folder.DoesExist(SessionVar.Expand("%CommonFilesFo lder%\SMS"));
if bresult then
-- A while loop
while File.Find(SessionVar.Expand("%CommonFilesFolder%\S MS"), "*.ocx", false, false, nil, nil) do
-- Do something here\
sPath =SessionVar.Expand("%CommonFilesFolder%\SMS")
sFolder = String.SplitPath("sPath");
sFile = sFolder.Filename;
sExt = sFolder.Extension;
-- get and set name of control
tFind = File.Find("C:\\", "sName", true, false, nil);
iCount = tFind.Count
-- check to see if another instance of the file exists. If it does, don't unregister or delete.
if iCount <= 1 then
System.UnregisterActiveX("sPath" .. "\\sName");
File.Delete("sFolder".."\\sName", false, false, false, nil);
end
Ulrich
08-11-2009, 04:16 PM
Hello,
this should be all you need.
-- check if folder exists
if Folder.DoesExist(SessionVar.Expand("%CommonFilesFolder%\\SMS")) then
-- find all OCX in folder and retrieve them in a table
tFiles = File.Find(SessionVar.Expand("%CommonFilesFolder%\\SMS"), "*.ocx");
-- process each element in the table
for i, file in tFiles do
-- unregister
SetupData.WriteToLogFile("Info\tUnregistering ".. file .. "\r\n", true);
System.UnregisterActiveX(file);
-- delete
SetupData.WriteToLogFile("Info\tDeleting ".. file .. "\r\n", true);
File.Delete(file);
end
-- cleanup
Folder.DeleteTree(SessionVar.Expand("%CommonFilesFolder%\\SMS"));
else
SetupData.WriteToLogFile("Info\t" .. SessionVar.Expand("%CommonFilesFolder%\\SMS") .. " does not exist\r\n", true);
end
Ulrich
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.