PDA

View Full Version : Problem w/File.IsInUse on Win 2K


Puppet
03-16-2006, 11:39 PM
File.IsInUse seems to work fine on XP but always returns TRUE on 2000. The program is definately not running already. Has anyone else encountered this? If so, what was the solution? Am I doing something wrong? Any help is greatly appreciated.

in_use_result = File.IsInUse(SessionVar.Expand("%AppFolder%\\MyProgram.exe"));
if (in_use_result ~= true) then

.
.
.
.
The grass may not be greener on the other side . . . but it just might have less weeds. :D

TJS
03-17-2006, 06:16 AM
In the code you posted you do not check if your File.IsInUse is true... just that it is not true (which could mean false or nil). Also, there seems to be an extra space in your action:

in_use_result = File.IsInUse(SessionVar.Expand("%AppFolder%\\MyProgram.exe"));

Tek
03-17-2006, 12:01 PM
FYI, that extra space sometimes occurs with this forum script (and others) when you don't place your code within the [ code ] and [ /code ] tags.

TJS
03-17-2006, 12:06 PM
Thanks Tek.

Sorry if i misdirected...

TJS
03-17-2006, 12:19 PM
Darryl or Mark,

Could this one be a cousin to the File.Install() issue?

Puppet
03-17-2006, 09:56 PM
Thanks TJS. You definitly didn't misdirect. The program name in the .sf7 script is fine in regards to there being no spaces. It was my fault, I should have used the proper tags. I'll put future code pastes inside the tags.:yes

The script works fine every time in XP it's just in 2k, desktop or server, it never works. I have tried over and over. Used task manager to ensure the file was not running. There is one thing I would like to add. The exe that I'm checking if already running by using file.isinuse is a file that's part of the archive setup.exe. Is it possible that some file handle (or something similar) is left open to the file after it is extracted and is inherent in 2K and not XP? Is there a sf7 function that could "release" or "close" a file after is has been unarchived?

I'm going to change the code to check for a condition of true as recomended by TJS. I hope that does the trick.

TJS
03-17-2006, 10:17 PM
np Puppet... This could be a red herring but the File.Install issue I referenced above was one that I believe IR fixed in a previous version of TrueUpdate 2.0.0.0 (shares a lot of code with SF7). The issue seemed to lock files when they shouldn't have been and prevent copying. Here's the thread...

http://www.indigorose.com/forums/showthread.php?t=11991&highlight=mcgill

What version of SF7 are you running?

Puppet
03-17-2006, 10:34 PM
TJS, as I was looking to change the code to check for a true condition and realized that the conditional statement always returns TRUE (True) in 2K. Unfortunately that's the problem - it always true. That is why my conditional statement is the way it is. I'll take anything but true in 2k; nil, false, voltzwagen, anything - but it's always true.

If I could unlock it would be great but I guess that won't do either since if the file is really in use, as it sometimes is, it would defeat the purpose of the isinuse check.

The version is 7.0.1.0

TJS
03-17-2006, 10:47 PM
Great scott!!! 7.0.1.0 was released in October.... of 2004! Just for giggles, try the upgrade... they've addressed tonnes of issues:

http://www.indigorose.com/forums/showthread.php?t=15407

http://www.indigorose.com/files/suf70/readme.htm

Puppet
03-17-2006, 10:49 PM
I just though of something else to try. I'm doing the check on post install. I'm going to move the inuse check to pre-install and set a variable (yes, no -or- true,false) to use in a condition to decide the actions during post install.

Puppet
03-17-2006, 10:51 PM
Yes, it's a vintage version. :o