简体   繁体   中英

Windows service Problem When Accessing Remote Machine File

I created a Windows Service which Access File from Remote Machine. but It gives error in Log file that File Does Not Exist.When i deployed it then and then only it gives error otherwise when i am debugging from Visual Studio 2005 then it is working fine. I tried to change Properties of Service from Log On tab. gives Logon as: then choose this Account and Gives Name of Remote Machine and Password Still it is not working. Please Help me out.

Code:

if (File.Exists(FileName))
{


}
else
{
  Log.append("File Not Exist Path=:" + FileName, 75);
}

Error:

File Not Exist Path=: \\Computer-01\\Trend Till_04Feb\\Trend Till_04Feb\\TREND\\128.DBF

I assume you are using ServiceProcessInstaller and ServiceInstaller.

The most important property is Account within the ServiceProcessInstaller class. It specifies the Windows account under which the service runs (security context). The following options are available:

LocalService: Service presents the computer's credentials to remote servers.

LocalSystem: Service presents anonymous credentials to remote servers.

NetworkService: Service has limited local privileges and presents the computer's credentials to remote servers.

User: A local or network account is specified. You may specify the necessary username and password via properties, or you may type them during installation. The Service uses the security context of the specified user account.

Following three options are provided to specify how your service is started.

Manual :- The user starts the service.

Automatic :- The service starts automatically when the system starts.

Disabled :- The service is not available for use.

  1. Go to Properties of ServiceInstaller object and set ServiceName and StartType to Automatic.

  2. Go to Properties of ServiceProcessInstaller and set Account property to LocalService. This causes the service to run on local service account.

HTH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM