Archive: !tempfile problem on WIndows 2003 server


!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.


Can you add a call to GetLastError() in the code and see what it says?


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.


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??


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


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.


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?


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.


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.


Maybe makensis somehow runs as a limited user with no access to those directories?


Try running it with FileMon and see what happens when it tries to create the temporary file in %TEMP%.


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?


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?


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.


This is a guest account. Is it possible to set a TEMP variable for this account?


Of course. Every user can have environmental variables.


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?


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.