cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

CreateFile always return error code (-1) - please help

Hello everyone,

I'm trying to write some logging activity to text file using the installscript.
Basically, it's should be a simple task (as seen on InstallShield help)
Here is my code:

logPath = "c:\\";
logFileName = "gil.log";
nvRet = CreateFile ( nvFileHandle, logPath, logFileName);
if ( nvRet < 0) then
NumToStr(nvRetStr,nvRet);
MessageBox("Error(" + nvRetStr + ") - Cannot create log file: " + logPath + logFileName,INFORMATION);
exit;
else
MessageBox("Successfully created log file: " + logPath + logFileName,INFORMATION);
endif;

The problem is that i always get -1 from CreateFile, i've tried to change file location, name, different PC, running in debug and release setup.exe, it always the same... error code -1.
I can't think of anything else which may causing this error, and furthermore - i can't seem to find proper documentation or list of error code and reasons.

Will appreciate any help or suggestions, Gil.
Labels (1)
0 Kudos
1 Reply
Highlighted
Flexera
Flexera

Re: CreateFile always return error code (-1) - please help

Sometimes you can get a clearer picture of what's taking place on the machine if you use a tool like Process Monitor. Similar information may be available in InstallScript through Err.LastDllError as well.

The one thing that jumps out at me with the path you mention (and is used in the example) is that it likely requires elevated privileges to write to that location. Depending on how your function is invoked, it's possible that it doesn't have the required privileges. By contrast, FOLDER_TEMP shouldn't require extra privileges, so maybe try that instead of "C:\\".
0 Kudos