Solved

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

Posted on 2007-11-15
8
2,998 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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
 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

778 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