>I have a C# program that creates a .csv file and emails it.
>Recently the client asked to have it run automatically, so I added to function to an .exe that is fired periodically by a custom Windows Service.
>If I log in to the client's machine and click the .exe all goes well.
>However, when the service fires the .exe, we get the following error:
>
>Prowler Error- 03/28/19
> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
> at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
> at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
> at System.IO.StreamWriter..ctor(String path)
> at AnalysisClassess.AnalysisMethods.SendPickupData() in q:\ssprowlersource\AnalysisClasses\AnalysisMethods.cs:line 188
> at AnalysisClassess.AnalysisMethods.ExecuteReview(DateTime lastreviewdatetime) in q:\ssprowlersource\AnalysisClasses\AnalysisMethods.cs:line 105
> at ssprowler.ProwlerMethods.StartApp() in q:\ssprowlersource\ProwlerMethods.cs:line 56
>
>It seems to indicate that there is some kind of privilege issue with the file creation.
>Any ideas?
Yes, you would need to scale that security up to the Windows Service credentials. When it runs, it runs under a different account that yours when you are directly on the console.
In the Windows Service Log On panel, you may select This account and add the required credentials.