473,802 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

windows service - 2 simple (I hope) questions

Hello,

I've written and installed windows service in C#. I have two questions:

1)

File.Open("lock ", FileMode.OpenOr Create, FileAccess.Read , FileShare.None)
does not create the file even if it doesn't exist.

Also:
Directory.Exist s(ConfigDirecto ryName)
returns always true (even if the directory doesn't exists)

I am sure paths are OK, my service runs under LocalSystem account which has
necessary (all, in fact) rights to the application directory. The service
CAN create files in the directory (I've checked).

The same code run from console application works fine.

What may be wrong? Why my service tells me files and directories exist, when
they don't? :)

2)

Is there some way to control the order in which services stop when the
system shuts down? My service depends on WMI, I have specified this in the
code. But when OnShutdown() code is running, I'm positively sure WMI is no
longer working.

I'd appreciate any help,
Jan
Jul 21 '05 #1
3 1203
"Jan Waga" <jw***@sim.com. pl> wrote in message
news:OI******** ******@tk2msftn gp13.phx.gbl...
Hello,

I've written and installed windows service in C#. I have two questions:

1)

File.Open("lock ", FileMode.OpenOr Create, FileAccess.Read , FileShare.None)
does not create the file even if it doesn't exist.

Also:
Directory.Exist s(ConfigDirecto ryName)
returns always true (even if the directory doesn't exists)

I am sure paths are OK, my service runs under LocalSystem account which
has
necessary (all, in fact) rights to the application directory. The service
CAN create files in the directory (I've checked).

The same code run from console application works fine.

What may be wrong? Why my service tells me files and directories exist,
when
they don't? :)


Are you sure that you're looking in the correct directory? When a service
starts, it's default directory is %SystemRoot%\Sy stem32. If you look there,
I think that you'll find your "lock" file and the directory that
ConfigDirectory Name points at.

Jul 21 '05 #2
You're right of course. I was sure that default directory would be
application directory. I didn't check it.
I'm still working on the second matter, though...:)

Thank you for your help.
Jan
Jul 21 '05 #3
For society;)
There is no way you can control order in which services shut down (during
system shutdown).
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2200
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My issue is simply getting timers to work. I have a DatabaseManager.DataManagerFacade which contains a timer. Every 6 seconds it updates stock data using an online webservice. I wrote have 2 possible startup projects to make the service work. One...
4
9026
by: Kris | last post by:
I have a Windows Service in C# talking to a serial port and using Remoting. It also uses several COM objects. On customer's computer the service will occassionally hang somewhere - the service still shows on a Task Manager list. In Services it says it is still running. However there is no way to stop it other than by rebooting the whole computer. No exception (including non-CLS) is ever generated. I added a separate System.Timers.Timer...
3
14966
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim swLog As StreamWriter = File.CreateText("C:\myLog.txt") swLog.WriteLine("My Windows Service has just started.") swLog.Close() : swLog.Flush() End Sub
3
2621
by: Chris Dunaway | last post by:
I am writing a Windows Service that reads and processes files on a set schedule. I want to create a second app that can monitor the Windows service. The Windows service will write trace messages at certain points while executing. The monitoring app I want to write will be very simple, just picking up these traces and displaying them to show progress of the service. My question is what is the best method of communication between the...
3
283
by: Jan Waga | last post by:
Hello, I've written and installed windows service in C#. I have two questions: 1) File.Open("lock", FileMode.OpenOrCreate, FileAccess.Read, FileShare.None) does not create the file even if it doesn't exist. Also:
3
5218
by: Miriam | last post by:
Hello, I created a Windows Service in VB.NET, which is to purge files periodically in the local system and also in the shared network drive. Here is my problem: 1. If I set the “Account” property of ServiceProcessInstaller to “Local Service” or to “NetWorkService”, it won’t work for both local and network shared directories. (I use log on as this account “NT AUTHORITY\LocalService” for “Local Service” or “NT...
6
1517
by: Jason Richmeier | last post by:
I have encountered a problem with the installation of a Windows service. I know I have done this in the past so I am at a loss as to what I might be doing wrong. When I create a setup project for a Windows Service project, build and then run it, the installation completes successfully but the service does not show up in the service control panel. If I install the service using installutil.exe the service will install just fine. Any...
2
4022
by: Sourcerer | last post by:
I posted these on another group, but was redirected here, so here are my two posts and my questions: Post #1: I've started my first practice windows service project in C#, and I'm already stuck. Let's say I'm trying to make a simple service (and useless, but good for practice). It is supposed to listen on port which is stored in its configuration
41
11667
by: pbd22 | last post by:
Hi. I know my windows service works when i run it in debug mode on my dev machine. It also works in release mode on my dev machine. But, when I move the service to a production server, it exits immediately with a start/stop/nothing to do error. What could be wrong?
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.