英文:
Seems that $TEMP folder path in NSIS does not match %TEMP% windows variable
问题
I inherited a project that I'm trying to update. It uses NSIS 3.0b2 (I also tried with 3.08 and had the same issue).
I'm trying to download a file (valid URL) to the $TEMP variable, however I see a "copy failed" error.
By printing the $TEMP variable I see that it is "C:\Users\JSMITH~1\AppData\Local\Temp" (note, Using John Smithy as an example username)
This style user folder doesn't seem to exist on my machine. %temp% takes me to "C:\Users\jsmithy\AppData\Local\Temp"
Presumably that is the expected folder for $TEMP in my .nsh script. This was probably originally designed for windows 7 and now it's running on windows 10. I assumed NSIS 3.08 would fix that since 3.0b2 was a beta release for win10 but I see the same $temp path.
Is this defined anywhere? What is the proper way to fix this path? (I've seen posts that just create a new variable, but I'm more curious about where NSIS is pulling the "old style" username from that doesn't seem supported anymore).
"old style" meaning Users\JSMITH~1 vs. "new style" Users\jsmithy
英文:
I inherited a project that I'm trying to update. It uses NSIS 3.0b2 (I also tried with 3.08 and had the same issue).
I'm trying to download a file (valid URL) to the $TEMP variable, however I see a "copy failed" error.
By printing the $TEMP variable I see that it is "C:\Users\JSMITH~1\AppData\Local\Temp" (note, Using John Smithy as an example username)
This style user folder doesn't seem to exist on my machine. %temp% takes me to "C:\Users\jsmithy\AppData\Local\Temp"
Presumably that is the expected folder for $TEMP in my .nsh script. This was probably originally designed for windows 7 and now its running on windows 10. I assumed NSIS 3.08 would fix that since 3.0b2 was a beta release for win10 but I see the same $temp path.
Is this defined anywhere? What is the proper way to fix this path? (I've seen posts that just create a new variable, but I'm more curious about where NSIS is pulling the "old style" username from that doesn't seem supported anymore).
"old style" meaning Users\JSMITH~1 vs. "new style" Users\jsmithy
答案1
得分: 1
NSIS调用GetTempPath
来解析$temp
。以~1结尾的文件名表示短文件名,为什么它们返回短文件名,可能是为了兼容性,您可能需要向Microsoft询问。
如果您真的想要长文件名,可以执行以下操作:
System::Call 'kernel32::GetLongPathName(t"$temp", t.r1, i${NSIS_MAX_STRLEN})'
MessageBox MB_OK $1
英文:
NSIS calls GetTempPath
to resolve $temp
. A filename ending with ~1 indicates a short name, you would have to ask Microsoft why they are returning the short name, probably for compatibility.
If you really want the long name you can do
System::Call 'kernel32::GetLongPathName(t"$temp", t.r1, i${NSIS_MAX_STRLEN})'
MessageBox MB_OK $1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论