Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

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
0
kepeter
Asked:
kepeter
  • 7
  • 5
  • 2
  • +1
1 Solution
 
SysExpertCommented:
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 !

0
 
jatcanCommented:
Sounds like you're writing a virus?
0
 
kepeterAuthor Commented:
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.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
SysExpertCommented:
If your company developed them, then tell them to use DOS names.
Very simple !

I hope this helps !
0
 
kepeterAuthor Commented:
Probably this is the most simple way, however we have more than 250 files (dll, ocx, exe) to rename!!!
0
 
jatcanCommented:
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.

0
 
jatcanCommented:
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.

0
 
jatcanCommented:
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.
0
 
jatcanCommented:
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.
0
 
kepeterAuthor Commented:
I check these different solutions, but meanwhile...
My problem exists only on windows98 and not WinNT or W2K.
0
 
kepeterAuthor Commented:
I check these different solutions, but meanwhile...
My problem exists only on windows98 and not WinNT or W2K.
0
 
ComTechCommented:
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
0
 
jatcanCommented:
Well, if it's not working then I guess the above answer of re-naming files may be your solution. Long process but you know it will work.
0
 
kepeterAuthor Commented:
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!
0
 
jatcanCommented:
Nno thank you. Your question prompted me to learn a bit about something I never would look into myself...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now