RE: Windows Service app to access network
From: Victor Urnyshev [MSFT] (victoru_at_online.microsoft.com)
Date: 05/28/04
- Next message: vmb: "Database of english words?"
- Previous message: Goran Djuranovic: "File or assembly name FxMdacPlugIn, or one of its dependencies, was not found"
- In reply to: DH: "RE: Windows Service app to access network"
- Next in thread: DH: "RE: Windows Service app to access network"
- Reply: DH: "RE: Windows Service app to access network"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 May 2004 18:46:17 GMT
The problem might be the security restrictions. Unless overridden, windows
services start under system account credentials, not the current logged in
user credentials. This system account might have no access to the share.
Please make sure that either the system account has access to the share, or
override the account for the service via Services applet in Administrator
tools in Windows.
Please let me know if it helps.
--
Victor Urnyshev [MSFT]
This post is "AS IS" with no warranties, and confers no rights.
--------------------
|Thread-Topic: Windows Service app to access network
|thread-index: AcRELQeM5vqRM7gVSsuhCqKURPtv4Q==
|X-WN-Post: microsoft.public.dotnet.general
|From: "=?Utf-8?B?REg=?=" <anonymous@discussions.microsoft.com>
|References: <00E10FC3-3B54-412D-ACCF-0606E11162BC@microsoft.com>
<PWA$1W2QEHA.3468@cpmsftngxa10.phx.gbl>
|Subject: RE: Windows Service app to access network
|Date: Thu, 27 May 2004 13:56:06 -0700
|Lines: 116
|Message-ID: <EC7CF5BA-998C-4148-BA83-1FC59E83788C@microsoft.com>
|MIME-Version: 1.0
|Content-Type: text/plain;
| charset="Utf-8"
|Content-Transfer-Encoding: 7bit
|X-Newsreader: Microsoft CDO for Windows 2000
|Content-Class: urn:content-classes:message
|Importance: normal
|Priority: normal
|X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
|Newsgroups: microsoft.public.dotnet.general
|Path: cpmsftngxa10.phx.gbl
|Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:135459
|NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
|X-Tomcat-NG: microsoft.public.dotnet.general
|
|Hi Victor:
Please see the code on my Windows Service: (Here timer2 tried to access a
flag file in a network, but it was failed to access. However if I changed
to C:\Temp\Timerflag.ok, the service worked. I am using System.IO to access
flag file).
Thanks.
Imports System.ServiceProcess
Public Class MyNewService
Inherits System.ServiceProcess.ServiceBase
#Region " Component Designer generated code "
Public Sub New()
MyBase.New()
InitializeComponent()
If Not EventLog.SourceExists("MySource") Then
EventLog.CreateEventSource("MySource", "MyNewLog")
End If
EventLog1.Source = "MySource"
EventLog1.Log = "MyNewLog"
End Sub
'UserService overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' The main entry point for the process
<MTAThread()> _
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New
MyNewService}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents EventLog1 As System.Diagnostics.EventLog
Friend WithEvents Timer1 As System.Timers.Timer
Friend WithEvents Timer2 As System.Timers.Timer
Private WithEvents Process1 As System.Diagnostics.Process
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.EventLog1 = New System.Diagnostics.EventLog
Me.Timer1 = New System.Timers.Timer
Me.Timer2 = New System.Timers.Timer
Me.Process1 = New System.Diagnostics.Process
CType(Me.EventLog1,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.Timer1,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.Timer2,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.ServiceName = "MyNewService"
CType(Me.EventLog1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Timer1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Timer2, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
#End Region
Protected Overrides Sub OnStart(ByVal args() As String)
EventLog1.WriteEntry("In Test OnStart")
Timer2.Enabled = True
End Sub
Protected Overrides Sub OnStop()
EventLog1.WriteEntry("In Test OnStop.")
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Dim Ret As Integer
Timer1.Enabled = False
Process1.StartInfo.FileName = "C:\SRVAPP\PESRVAPP.exe"
Process1.StartInfo.Arguments = "Retail"
Process1.StartInfo.WorkingDirectory = "C:\SRVAPP"
Process1.StartInfo.UseShellExecute = False
Process1.StartInfo.CreateNoWindow = False
Process1.Start()
Timer2.Enabled = True
End Sub
Private Sub Timer2_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer2.Elapsed
If
(System.IO.File.Exists("\\171.177.173.29\EngBat\Engine\TimerFlag.ok")) Then
'--"C:\Temp\TimerFlag.ok"
Timer2.Enabled = False
System.IO.File.Delete("\\171.177.173.29\EngBat\Engine\TimerFlag.ok")
EventLog1.WriteEntry("TimerFlag was deleted.")
Timer1.Enabled = True
End If
End Sub
End Class
|
- Next message: vmb: "Database of english words?"
- Previous message: Goran Djuranovic: "File or assembly name FxMdacPlugIn, or one of its dependencies, was not found"
- In reply to: DH: "RE: Windows Service app to access network"
- Next in thread: DH: "RE: Windows Service app to access network"
- Reply: DH: "RE: Windows Service app to access network"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|