[英]NSIS $TEMP Has Different Value
I have been noticed $TEMP param has different value when you:我注意到$TEMP参数在您执行以下操作时具有不同的值:
Running manually will result $TEMP = C:/Users/username/AppData/Local/Temp手动运行将导致 $TEMP = C:/Users/username/AppData/Local/Temp
Running from App with Admin rights = C:/Windows/Temp从具有管理员权限的应用程序运行 = C:/Windows/Temp
CONDITION:健康)状况:
I have an installer that requires system reboot to finish the process.我有一个安装程序,需要重新启动系统才能完成该过程。
To achieve that, I make a copy of installer in the $TEMP, and put the path in RunOnce为了实现这一点,我在 $TEMP 中制作了一份安装程序的副本,并将路径放在RunOnce 中
PROBLEM:问题:
The function works fine (after reboot, the program is updated with new version).该功能工作正常(重启后,程序更新为新版本)。
However, at the end of installation process, I am unable to delete the copy of installer because the $TEMP = C:/Users/username/AppData/Local/Temp when running the installer by RunOnce .但是,在安装过程结束时,我无法删除安装程序的副本,因为 $TEMP = C:/Users/username/AppData/Local/Temp通过RunOnce运行安装程序时。
In fact, the copy of installer is located in C:/Windows/Temp实际上,安装程序的副本位于C:/Windows/Temp
QUESTION:题:
Is it possible to force the $TEMP to always be = C:/Windows/Temp ?是否可以强制 $TEMP 始终为 = C:/Windows/Temp ?
Is there any better solution to workaround the case of installation with system reboot?有没有更好的解决方案来解决系统重启安装的情况?
NSIS gets its $Temp
variable like this: NSIS 像这样获取它的$Temp
变量:
First it tries GetTempPath
.首先它尝试GetTempPath
。 That function tries (in order): %TMP%
, %TEMP%
, %USERPROFILE%
, and %WINDIR%
, and it returns the first variable that exists.该函数尝试(按顺序): %TMP%
、 %TEMP%
、 %USERPROFILE%
和%WINDIR%
,并返回存在的第一个变量。
NSIS then tries to write to this directory and if that fails NSIS uses %WINDIR%\\Temp
. NSIS 然后尝试写入此目录,如果失败,NSIS 使用%WINDIR%\\Temp
。
Admin vs non-admin nor UAC elevation is not really the cause of what you are seeing.管理员与非管理员或 UAC 提升并不是您所看到的真正原因。 Sounds more like a configuration or Anti-Virus issue.听起来更像是配置或防病毒问题。
You can force $Temp
to a specific directory if you really want to in NSIS 3:如果你真的想在 NSIS 3 中,你可以强制$Temp
到一个特定的目录:
Function .onInit
UnsafeStrCpy $Temp "$Windir\Temp"
CreateDirectory $Temp
/*
#--# Uncomment to apply the same %TEMP% to child processes #--#
System::Call 'KERNEL32::SetEnvironmentVariable(t"TEMP",t"$Temp")'
System::Call 'KERNEL32::SetEnvironmentVariable(t"TMP",t"$Temp")'
*/
FunctionEnd
I don't actually understand your issue though because the RunOnce entry can tell what it's path is by using $ExePath
.我实际上并不理解你的问题,因为 RunOnce 条目可以通过使用$ExePath
来判断它的路径是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.