.NET Assembly can't create tmp logs where path contains !
Receive the following error when using the .NET assembly in powershell code:
Error:
Exception calling "Open" with "1" argument(s): "Timeout waiting for WinSCP to respond - Log file C:\Users\!whatever\AppData\Local\Temp\3\wscp1ADC.0398CDFA.tmp was not created in time, please make sure WinSCP has write permissions to the folder"
Calling Code:
[Reflection.Assembly]::LoadFrom($WinSCPInstLocation) | Out-Null
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = $WinSCPHost
$sessionOptions.UserName = $WinSCPUser
$sessionOptions.Password = $WinSCPPwd
$sessionOptions.SshHostKey = $WinSCPHostKey
$session = New-Object WinSCP.Session
$session.Open($sessionOptions)
Notes:
-Because the log file isn't created, the session is never established.
-The '!whatever' user has full access to the mentioned directory
-Only happens when the log file path contains a '!'. If the TEMP and TMP environment variables don't contain a '!' the script executes correctly.
-The GUI seems to behave fine
-Changing the settings for the temp file location from within the GUI isn't picked up by the .NET Assembly
I am looking for a fix/workaround that doesn't entail changing the system environment variables/running the app with a different account. Is there a session option for the logs in the .NET assembly that can be set to get around this?
Thanks
Error:
Exception calling "Open" with "1" argument(s): "Timeout waiting for WinSCP to respond - Log file C:\Users\!whatever\AppData\Local\Temp\3\wscp1ADC.0398CDFA.tmp was not created in time, please make sure WinSCP has write permissions to the folder"
Calling Code:
[Reflection.Assembly]::LoadFrom($WinSCPInstLocation) | Out-Null
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = $WinSCPHost
$sessionOptions.UserName = $WinSCPUser
$sessionOptions.Password = $WinSCPPwd
$sessionOptions.SshHostKey = $WinSCPHostKey
$session = New-Object WinSCP.Session
$session.Open($sessionOptions)
Notes:
-Because the log file isn't created, the session is never established.
-The '!whatever' user has full access to the mentioned directory
-Only happens when the log file path contains a '!'. If the TEMP and TMP environment variables don't contain a '!' the script executes correctly.
-The GUI seems to behave fine
-Changing the settings for the temp file location from within the GUI isn't picked up by the .NET Assembly
I am looking for a fix/workaround that doesn't entail changing the system environment variables/running the app with a different account. Is there a session option for the logs in the .NET assembly that can be set to get around this?
Thanks