Solved

How to call windows service from windows application - (Vista issues) XP is ok

Posted on 2007-11-15
8
2,997 Views
Last Modified: 2010-04-21
I wrote a windows service and a windows application in VS2005 in VB.  The application monitors a folder for changes and calls the windows service if there are new files added to the folder. The windows service FTP's the files to an FTP server then shuts down and the application continues running.

The program works flawlessly on XP, but on Vista, the windows application fails to call the windows service.  I'm using a ServiceController and in the code I have Me.ServiceController1.Start().  I have error/success messages from the application and service writing to a custom event log I've created for this, but the only error message I'm getting is "Cannot open <service Name> on computer '.' " The properties for the ServiceController have the right ServiceName and have a single decimal for the MachineName since the service is local.  How do I fix this so my application calls the service successfully?  Since all I really want to do is call the windows service, is there a different way or a better to do what I'm looking for?
0
Comment
Question by:aperion
  • 4
  • 3
8 Comments
 
LVL 10

Accepted Solution

by:
ericwong27 earned 500 total points
ID: 20296492
It may due to insufficient user permissions. Maybe you can try following method
1. Locate the applications icon or short cut and Right click on it
2. From the Drop Down Menu select the Run As Administrator option

0
 
LVL 1

Author Comment

by:aperion
ID: 20296738
I can do that now, the problem is I don't want the user to have to do that everytime they want to run the program.  If I go in and click on Run As Admistrator, the program runs as expected.  But how do I configure the install package and/or the program to install with administrative priviledges so the user doesn't have to click on Run As Administrator everytime?
0
 
LVL 1

Expert Comment

by:adam_ingeniti
ID: 20318017
What account does the service run under?

Perhaps you need to install your application to run as that user also?
0
 
LVL 1

Author Comment

by:aperion
ID: 20318037
The service runs under the local system account.  The installation package installs the application and the service for all users.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Expert Comment

by:adam_ingeniti
ID: 20318057
0
 
LVL 1

Author Comment

by:aperion
ID: 20318079
It sounds promising, but I won't be able to look at it in more detail until later in the week.  It'll also take me some time to convert it to VB.
0
 
LVL 1

Expert Comment

by:adam_ingeniti
ID: 20318093
This might help with the conversion part:
http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

(it's not perfect, but it's quite useful for those times where you just aren't quite sure how to do something in the other language).
0
 
LVL 1

Author Closing Comment

by:aperion
ID: 31409501
I didn't want the user to have to do this and I haven't found a solution to this anywhere else, so I suppose I'll have to settle for Vista's new way of doing things. Thanks, I appreciate your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now