PDA

View Full Version : FilesInUse



trevrobwhite
07-18-2007, 09:58 AM
This might be one for Rob (sorry to hassle you today), I've got support to look at this but I could still do with a better solution.

My Installer replaces Microsoft Word Template files, but sometimes these are held in use, but the Installer Services doesn't display the FilesInUse dialog for these instead it errors about exclusive access.

So I now manually check to see if the files are locked and use SdFilesInUse, however the problem is if the users choose Ignore to my dialog and the main executable is open they get two files in use dialogs (because I cannot Schedule a force reboot before InstallValidate).

So I thought I'd populate the FileInUseProcess property, this works if I put the FilesInUse dialog into the InstallUI Sequence but as soon as it hits InstallValidate it wipes out the records I put in FilesInUseProcess.

Is there any way I can stop InstallValidate overwriting my property or tell the installer to take note of my .dot files. I'm surprised the installer service doesn't associate .dot files with Microsoft Word as its a common Microsoft product.

Why can't things be simple - this stomped the support people as well at Macrovsion!

Thanks in advance.

I'm using a Basic MSI project by the way.

RobertDickau
07-19-2007, 09:16 AM
Instead of populating FilesInUseProperty, perhaps try modifying the in-memory FilesInUse table? The MSI help topic "Sending Messages to Windows Installer Using MsiProcessMessage" also seems to have an approach that might work...

trevrobwhite
07-19-2007, 09:34 AM
Rob,
How would I code that in InstallScript? I currently do the following (thanks to your good self)

Currently I do this to record it:


hDB = MsiGetActiveDatabase(hMSI);
MsiDatabaseOpenView(hMSI,"SELECT * FROM `ListBox`
WHERE `Property`='FileInUseProcess'", hViewlist);

MsiViewExecute(hViewlist, NULL);

hRecordlist = MsiCreateRecord(4);

MsiRecordSetString(hRecordlist, 1, "FileInUseProcess");
MsiRecordSetInteger(hRecordlist, 2, r);
MsiRecordSetString(hRecordlist, 3, "Files_" + svListIndex );
MsiRecordSetString(hRecordlist, 4, "Microsoft Word - " + svParse );

MsiRecordSetString(hRecordlist, 4, "Unknown Applicaiton - " + svParse );

// can only temporarily modify running MSI database
MsiViewModify(hViewlist, MSIMODIFY_INSERT_TEMPORARY, hRecordlist);

MsiViewGetError ( hViewlist, svErr, nBuffer );
SprintfBox ( MB_OK, "Error", "%s\n%i", svErr, nBuffer );


MsiViewClose(hViewlist);
MsiViewClose(hViewprop);

RobertDickau
07-19-2007, 01:46 PM
If you have the name of the EXE to shut down and its process ID, something like this before InstallValidate seems to work in VBScript:
Set myrec = Installer.CreateRecord(2)

myRec.StringData(1) = "SampleApp.exe"
myRec.IntegerData(2) = 4321
Session.Message &H05000000, myrec ' msiMessageTypeFilesInUse, that is
It doesn't seem to respect the Exit button, but perhaps it's a start...

trevrobwhite
07-20-2007, 03:50 AM
Thanks for that, its a shame MSI cannot realise a .dot file is MSWord and deal with it itself but I'll give this a bash.