title: writing file in %TEMP% fails silently
body: <p>I have this function which writes to my log file.  It is failing silently.  In that there are no errors raised in this function, it just fails to create or write to the file.  I'm trying to write to <code>%TEMP%\myappname.log</code>.  It also fails in <code>%USERPROFILE%\Desktop\myappname.log</code>.  Server is Windows Server 2008 R2 Standard.
  I've encountered this with writing to the application folder with other programs so moved to writing to the <code>%TEMP%</code> directory and this solved it.  But this system won't even let me write to the <code>%TEMP%</code> directory.
  Yes I tried running as administrator too and it didn't help.
  %TEMP% in this case resolves through <code>ExpandEnvironmentStrings</code> to <code>C:\Users\sa\AppData\Local\Temp\2</code>
  So g_strLogPath is <code>C:\Users\sa\AppData\Local\Temp\2\myappname.log</code>.</p>
  
  <pre><code>Public Function LogMessage(ByVal strInput As String, Optional ByVal blnDate As Boolean = False) As Boolean
  
     Dim intFileNumber As Integer
  
     On Error GoTo ErrorHandler
  
     If g_lngLogLevel &lt;&gt; 1 Then
        Exit Function
     End If
  
     If Len(g_strLogPath) = 0 Then
        SetLogPath
     End If
  
     If blnDate Then
        strInput = Format(Now, cstrLogDateFormat) &amp; " : " &amp; strInput
     End If
  
     intFileNumber = FreeFile
     Open g_strLogPath For Append As #intFileNumber
     Print #intFileNumber, strInput
     Close #intFileNumber
  
     LogMessage = True
  
     Exit Function
  
  ErrorHandler:
  
     MsgBox _
        "Error: " &amp; Err.Number &amp; vbCrLf &amp; _
        "Location: Module1.LogMessage" &amp; vbCrLf &amp; _
        "Line: " &amp; Erl &amp; vbCrLf &amp; _
        Err.Description, vbExclamation + vbOKOnly
  
  End Function
  </code></pre>