Link to home
Start Free TrialLog in
Avatar of kepeter
kepeter

asked on

Replace files with long-file-name

Hi,

 I have a little setup program, which replaces files in use by writing 'wininit.ini' and reboot.
 To be more precise I copy the new file to the desired location by an other name like 'ItsALongFileName.dll.tmp', than I write a line into the 'wininit.ini' that copies this file to 'ItsALongFileName.dll'.
 Unfortunately most of the files I have has long file name. Microsoft declares in PlatformSDK that 'Both DestinationFileName and SourceFileName must be short file names.'
 So before I write file names into the 'wininit.ini' I ask for the short file name of the specified file.
 The result of this, after reboot, is a file named 'ItsALo~1.dll', asumed that the original file was 'ItsALongFileName.dll'.

 How can I solve this problem?

Thanks
Peter
Avatar of SysExpert
SysExpert
Flag of Israel image

Try puttin name in quotation marks ""
this may help.

If not, then because it is rocessed at the DOS level, before windows loads long file name handling, there is no solution without using a custom installer that handles long file names.

I hope this helps !

Avatar of jatcan
jatcan

Sounds like you're writing a virus?
Avatar of kepeter

ASKER

To SysExpert,
 Quotation marks does not work...

To jatcan,
 Nothing between me and a virus. I talk about a setup program, that have to replace some files. All of them files that my company developed.
If your company developed them, then tell them to use DOS names.
Very simple !

I hope this helps !
Avatar of kepeter

ASKER

Probably this is the most simple way, however we have more than 250 files (dll, ocx, exe) to rename!!!
Sorry about the virus thing. That is what it sounds like but I shouldn't have said it. That being said....readt this, it is probably the answer to your problem, providing you don't mind requiring a reboot to complete the installation:

How to Replace In-Use Windows NT System Files (Q184408)

The Mv.exe tool is a 32-bit version of the POSIX MV tool. Mv.exe has the following syntax:

mv [/x [/d]] file1 [ file2 ...] target
The command-line switches are:

/x: Do not save files that are replaced.

/d: Delay file move until system reboot.

Q228930 How to Replace Currently Locked Files with Inuse.exe

Aslo,

ODE97: Setup Wizard Disk Images Do Not Contain Long File Names (Q174495)-explains that the wizard truncates the names and re-expands them to the long file name format during installation onto a supportive OS OR leaves them truncated on a non-supported OS.

This is the Office developers setup wizard so it may not suit your purposes.

AND here it is:

Windows 95 and Windows 98 use Wininit.ini to move, replace, or delete files that are currently in use. Wininit.ini is processed by Wininit.exe before the protected mode disk system is loaded. Long file names are only available when the protected mode disk system is running. This problem is caused by a limitation in Wininit.exe that does not support the long file name format. This issue is addressed in Windows NT and Windows 2000 because these operating systems support the use of the Win32 API MoveFileEx that supports long file names.



RESOLUTION
There are two possible ways to work around this problem. The first is: before the installation takes place, make sure that all the files that will be installed with long file names are not in use, so that the Installer will able to replace them using the long file name format.

The other way to work around this problem is to write a custom action in the .msi file. The custom action will do the file copy rather than letting the Wininit.ini do it. Use the custom action to copy files to a temporary directory and write an entry to the RunOnce key in the registry that will call a utility (a program or a script) that will copy the files to the correct folder after the reboot.



STATUS
This behavior is by design.

This is more specific to Windows 2000/XP



HOWTO: Move Files That Are Currently in Use (Q140570)


It basically states that wininit.ini is operating before the long file name handler and therefore cannot be used with long file names. It suggests that if you need long file name handling, you should make an entry inot the runonce key of the registry that will move, copy,replace file names after the long file name handler has been initiated and that further, use mv.exe to replace file names in use. This setup may require two reboots.

Good Luck.
Sorry about the aboive post, it actually nearly duplicates the previous post. I've read at least 20 documents on this subject since you first posted the question. They're getting a little blurred...the information is all valid though.
Avatar of kepeter

ASKER

I check these different solutions, but meanwhile...
My problem exists only on windows98 and not WinNT or W2K.
Avatar of kepeter

ASKER

I check these different solutions, but meanwhile...
My problem exists only on windows98 and not WinNT or W2K.
Hi kepeter@devx, sorry to intrude into your question, but I have changed you from Devx, and will begin gettin emails from EE home, rather than devx.

Thanks,
ComTech
CS Admin @ EE
ASKER CERTIFIED SOLUTION
Avatar of jatcan
jatcan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kepeter

ASKER

After checking out all the options I found that not good solution exists for Win98 (For WinNT and W2K we have MoveFileEx).
So I choose RunOnce registry key to solve my problem, for that and for the great effort jatcan invested to help me I give him these points.

Thank you!
Nno thank you. Your question prompted me to learn a bit about something I never would look into myself...