似乎 NSIS 中的 $TEMP 文件夹路径与 Windows 变量 %TEMP% 不匹配

huangapple go评论75阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月24日 01:17:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548185.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定