dfranck
2nd April 2012 23:02 UTC
File Command with \\?\ added to a variable path
I am trying to use the File command to add files to my installer. Due to the location of the files on my system, I run into the 255 char limit, thus requiring the need for \\?\ added to the front of my path. I initially was using a relative path to the files I wanted included in my installer, but when the limit was reached I had to change direction.
Does anyone have any good ideas, short of moving the files to a location with a shorter path in my directory tree, as to how I can use the File command with a variable path name.
I have tried passing a variable as Filespec in hopes that the value of the variable would be used, but the macro seems to pass the variable name instead of the path stored in Filespec.
!macro InstallFilesTo Path Filespec
SetOutPath "${Path}"
File /r "${Filespec}"
!macroend
I have tried many different approaches over the past few days, some syntax really questionable.... I am at a loss. I have tried pretty much everything I have seen posted online thus far, but I believe my situation is unique, because the installer I am trying to write needs to be able to be compiled on many different user's systems.
Any and all help is greatly appreciated.
Thanks,
Dan
Anders
3rd April 2012 22:44 UTC
What actually happens when you do File "\\?\c:\insane\path\myfile.ext"? Our internal limit is probably 1024 but the MS C run time might be getting in the way. Windows is limited to MAX_PATH (256) for ansi apps so you must use the unicode fork for any chance of the \\?\ prefix working. Other solutions are: subst, UNC drive mapping or junctions/symlinks to get the path shorter...
dfranck
4th April 2012 15:20 UTC
Anders, first off, thank you for your response. When I use the absolute path, File "\\?\c:\insane\path\myfile.ext", the compiler and the resulting installer works great.
When I pass "\\?\c:\insane\path\myfile.ext" in a $tempDir variable, the compiler gives File: "$tempDir" -> no files found. message along with Error in script "test.nsi" on line 21 -- aborting creation process.
I guess it doesn't make sense to me why I can use the absolute path when hard coded but not when passed in with a variable.
i.e.
File /r "\\?\c:\insane\path\myfile.ext"
Var /GLOBAL tempDir
StrCpy $tempDir "\\?\c:\insane\path\myfile.ext"
File /r $tempDir
I will take a look at the unicode fork and your other suggestions to see if I can get them to work for me before I say give and use a batch file to relocate the files, compile the installer, and then move the files back...or something along those lines.
Thanks again for the help.
Anders
4th April 2012 16:06 UTC
File does not take variables! Use a define...
dfranck
4th April 2012 21:45 UTC
Anders, here is my solution...thanks again for the help.
I'm using a batch file where I
SET "INSANE_PATH=\\?\%LONG_PATH%"
"%NSIS%\makensis.exe" /DFILE_DIRECTORY=%INSANE_PATH% myInstaller.nsi > myInstaller.log
Then in my nsi script I just call
File /r ${FILE_DIRECTORY}
This does the trick... Thanks again for the advice.
~Dan
Brummelchen
6th April 2012 21:41 UTC
this might help too
http://forums.winamp.com/showthread.php?t=343779
dfranck
6th April 2012 21:47 UTC
Thanks Brummelchen, I'll talk a look