- NSIS Discussion
- !tempfile problem on WIndows 2003 server
Archive: !tempfile problem on WIndows 2003 server
darthvader
14th August 2007 19:00 UTC
!tempfile problem on WIndows 2003 server
I get a !tempfile: unable to create temporary file. error on a Windows 2003 machine. I checked all the environment variables and everything is fine. Does anyone know what else could cause the problem?
I executed a small program on the machine which throws this error and this passed too. This code is from NSIS script.cpp file.
char buf[MAX_PATH], buf2[MAX_PATH];
GetTempPath(MAX_PATH, buf);
if (!GetTempFileName(buf, "nst", 0, buf2))
{
ERROR_MSG("!tempfile: unable to create temporary file.\n");
return PS_ERROR;
}
buf and buf2 were populated correctly.
kichik
14th August 2007 20:57 UTC
Can you add a call to GetLastError() in the code and see what it says?
darthvader
15th August 2007 03:56 UTC
Sorry i did not explain it properly, the problem is i get this error only when i am compiling the script otherwise it works fine.
darthvader
15th August 2007 17:03 UTC
This the last few lines before the compilation failed
!insertmacro: InstallLib
!tempfile: unable to create temporary file.
Error in macro __InstallLib_Helper_GetVersion on macroline 4 Error in macro InstallLib on macroline 86
When i execute the code as mentioned above it does not fail :(
Does anybody have any idea??
kichik
15th August 2007 21:29 UTC
I was talking about NSIS's source code. I've added the call and uploaded the compiled makensis.exe to:
http://stashbox.org/33659/makensis.zip
darthvader
17th August 2007 02:37 UTC
Thanks for the file. I am getting a Error code 5 (Access is denied) for the return of GetLastError. I checked it up on net why this would happen but no luck.
Please help.
darthvader
17th August 2007 06:49 UTC
Ok i hacked into the source code and added few statements to figure out what exactly is going wrong
Here is the output of the analysis
!tempfile: unable to create temporary file.
GetLastError:5
Output Of GetTempPath: C:\WINDOWS\
Output of GetTempFileName: urrentVersion\SharedDLLs
I still cant figure out how can an MSDN function fail like this?
kichik
17th August 2007 09:16 UTC
It would seem GetTempFileName doesn't not allow creating temporary files directly under C:\Windows. Start by verifying the TEMP and TMP environment variables and make sure they're not set to C:\Windows.
darthvader
18th August 2007 03:41 UTC
The problem is that the user is unable to create temp files in c:\windows. I am confused since the the variables
TMP=C:\Documents and Settings\User\LocalSettings\Temp
TEMP=C:\Documents and Settings\User\LocalSettings\Temp
USEPROFILE=C:\Documents and Settings\User
are set correctly. Do you know why would the query for these variables fail? According to MSDN only when query to all of these variables fail windows directory would returned :(
Could you please help me out.
kichik
18th August 2007 09:53 UTC
Maybe makensis somehow runs as a limited user with no access to those directories?
kichik
18th August 2007 12:07 UTC
Try running it with FileMon and see what happens when it tries to create the temporary file in %TEMP%.
darthvader
18th August 2007 15:31 UTC
The problem is the installer build is an automated process run by another user(i dont have access to the account, Hence faing a lot of problems). Hence i am unable to use the Filemon on that machine. Is there an other way?
darthvader
18th August 2007 16:00 UTC
makensis permisssion issue
I think i have found the problem. The GetTempPath is trying to query the registry for the TMP,TEMP and USERPROFILE keys. Since the user does not have any permissions to do so, all the calls to it are failing.
Hence the only option left is to return the windows directory(according to MSDN), since this also fails due to permissions issue of the user. the whole thing fails miserably:(.
Does makensis require all the builds to be run under Administrator mode(it doesnt mention this anywhere(correct me if I am wrong))? Is it possible to change the code for tempfile, delfile and execute(other bunch of stuff which does require administrator rights) to reflect all these?
kichik
18th August 2007 16:46 UTC
No, it doesn't require administrator privileges. It does, however, makes the reasonable assumption that it could create temporary files in the temporary directory. If this is an automated system, you can make it set the TEMP environment variable and point it to somewhere the user can write to.
darthvader
18th August 2007 17:03 UTC
This is a guest account. Is it possible to set a TEMP variable for this account?
kichik
18th August 2007 17:26 UTC
Of course. Every user can have environmental variables.
darthvader
18th August 2007 17:53 UTC
I just have a feeling that GetTempPath queries the registry for the environment variables. Hence its failing for the guest account. Could you please comment on this?
kichik
18th August 2007 17:56 UTC
The guest user has its own registry hive which it can query. No user can function without a hive. I have a guest account on my computer and it works perfectly fine with its own temporary directory.