Permissions To Start A Service
Mar 9, 2012
Hi.
I'm developing a project where I'm looking after a service: Smart Card.
I'm checking if it is closed. If it is closed then I'm checking if it is Disabled. If it is Disabled then I'm changing its status to Automatic and I'm starting the service. If the service is closed but the status is disabled I'm just open it.
The problem is that on my computer everything is working good, but when I'm trying to use it on other computer, if the service is disabled then everything is fine, but for example if the service is automatic and closed then I'm trying to start it, but I
receive the error which is telling that I don't have permissions.
My questions are:
1.How it is possible to have permissions to change the status from disable to auto and to start the service, but not to start it if the status is already automatic?
2. How can I give the permissions just for that using the code?
Here is the code what I'm using:
Dim controller As New ServiceController("SCardSvr")
If controller.Status.Equals(ServiceControllerStatus.Stopped) Then
'' getServicesForDomainComputer(Environment.MachineName.ToString())
'' EnsureTransactionManagerStarted(False)
Dim obj As ManagementObject
Dim inParams, outParams As ManagementBaseObject
Dim Result As Integer
obj = New ManagementObject("\.
ootcimv2:Win32_Service.Name='SCardSvr'")
'Change the Start Mode to Automatic
If obj("StartMode").ToString = "Disabled" Then
'Get an input parameters object for this method
inParams = obj.GetMethodParameters("ChangeStartMode")
inParams("StartMode") = "Automatic"
'do it!
outParams = obj.InvokeMethod("ChangeStartMode", inParams, Nothing)
Result = Convert.ToInt32(outParams("returnValue"))
If Result <> 0 Then
Throw New Exception("ChangeStartMode method error code " & Result)
End If
End If
controller.Start()
End If
View 5 Replies
ADVERTISEMENT
Oct 24, 2011
I'm developing a project where I'm looking after a service: Smart Card.I'm checking if it is closed. If it is closed then I'm checking if it is Disabled. If it is Disabled then I'm changing its status to Automatic and I'm starting the service. If the service is closed but the status is disabled I'm just open it.The problem is that on my computer everything is working good, but when I'm trying to use it on other computer, if the service is disabled then everything is fine, but for example if the service is automatic and closed then I'm trying to start it, but I receive the error which is telling that I don't have permissions.
1.How it is possible to have permissions to change the status from disable to auto and to start the service, but not to start it if the status is already automatic?
2. How can I give the permissions just for that using the code?
Here is the code what I'm using:
Dim controller As New ServiceController("SCardSvr")
If controller.Status.Equals(ServiceControllerStatus.Stopped) Then
'' getServicesForDomainComputer(Environment.MachineName.ToString())
[code]....
View 1 Replies
Mar 12, 2009
[code]...Cannot Start a Service After Changing 'Start' Property Through Registry
View 3 Replies
Sep 17, 2009
when I am using the following code. the kill all batch file internally calls a vbs cript like this when a batch file is called using CreateProcess() which internaly calls a vbs script like this cscript //e:vbscript xyz.vbs which intends stops and starts a service in remote PC as follows. But the service is stopping but it is not starting event though it start command is used what could be the reason...
sCommandLine = "SC \"&strMachineName&" stop xyzService"
WScript.Echo(sCommandLine)
Set poProcess = WSHShell.Exec(sCommandLine)
[code]....
View 4 Replies
Jan 5, 2011
I have written my first service that checks the status of servers. I have used the statement System.Threading.Thread.Sleep(86400000), so that the service will run, then sleep for 24hrs before running again.
My problem is i want the service to run at 7am every morning, when i install and start the service it will run from the time i start it. I dont have access to required computer at 7am.
Is there a way of setting the service to run at 7am on the first run? Was thinking a Loop, or timer but dont want to be eating resources up while it is not necessary.
View 10 Replies
Nov 9, 2010
I am trying to start a service on my machine from one of my applications and I get the following exception. I am using Windows 7 by the way.[code]...
View 1 Replies
Feb 3, 2011
I have a project in which we would like to do the following :Install a service that perform several tasks. this would be put on Computer A and B.Another computer C serves as a witness; At start, only A is running because the work it performs cannot be duplicated;Should A fail, then B must start. C should be the one that verify is one is running or not;Sholud A return back up after a fail, then B still runs and A is on stand-by;Should B then fail, C start A services,And So On.Is it possible, if so how ? Both A and B have a SQL server 2008 on them but this part is taken care of for us.I tried stopping a service (that I know is running) and it dosn't seem to work.[code]In this case, strServiceName is "Communication Interface" which is a service I recently add and started manually.I am running under windows 7.
View 2 Replies
Dec 9, 2007
how to start and stop a service using Visual Basic 2008 Express?I specifically need to write a small application that will start and stop the spooler service. In other words, the command line equivalent of:net stop spooler andnet start spoolerTIA
View 14 Replies
Dec 8, 2011
Here's my code. Is it blindingly obvious why my service won't run?[code]...
View 6 Replies
Aug 1, 2011
We create a window service that will launch multiple process of an application with different configuration. And application further communicate with sql server. It works fine when we start service manually from service manager. It launch all the process ( try with launching 3 process ). But when we test it by restart the machine and service launch automatically then it launch only one process third one. I check the event log in event viewer. I see the following message by MSSQL$MSSQLEXPRESS service
Login failed for user 'dduser'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]
one thing we also tried by delaying ( with thread sleep ) the code execution of service. Then by starting machine again , it launch 2 process , first one still not launch.
View 3 Replies
Jun 2, 2009
I created a simple service that does some inventory and records the data to a MySQL server. The service starts just fine when told to from the services administration panel. However, it will not on computer bootup. I get the famous error.
The InventoryService service failed to start due to the following error:The service did not respond to the start or control request in a timely fashion. I've read that logs can be a problem, so I disabled the autolog...but that didn't solve any problems. I believe it has something to do with the user not already being logged in and attempting to connect to a remote database. So, I added a function to check for internet connectivity before executing any inventory methods or SQL queries. This did not fix it either.
EDIT: I also am receiving the following error in the administrative logs. I create the service dependant upon the Tcpip service, but it still fails.A timeout was reached (30000 milliseconds) while waiting for the InventoryService service to connect.
View 1 Replies
Sep 21, 2009
I keep getting the error msg box[code]...
when trying to run a VB service that I developed. I just want to run it and attach a debugger to it.
View 1 Replies
May 23, 2012
I created a custom windows service in Visual Basic using Visual Studios '05.
The service is on our server which is running Windows Server 2003. I have installed the service, and it runs perfectly when I go into Computer Management and Start the service manually.
I have created a batch file to start the service using the NET START command. Whenever I run the batch file, the service doesn't start. I get this message from the command prompt[code]...
View 1 Replies
Oct 19, 2011
Is it possible to Start Windows Messenger service and set the Startup type to Automatic?
View 1 Replies
Oct 28, 2010
I have developed several Windows Services applications which all use SQL server. In some occasions, the customer shuts down the server and then restarts it the following morning. But then, my service is started BEFORE SQL Server starts and, of course, fails.
In which order are the services started ?
View 3 Replies
Jan 18, 2011
I want the presence of a text file in a folder to trigger a printing software and print using a template I already designed..all this should be done as a serviced..i.e. in the background coz I don't want my users to know how I am printing.
View 1 Replies
Dec 21, 2009
In Visual Studio when I try to start a windows service project it tells me I cant because I have to use "NET Start" and so forth. I remember in VS 2003 that when I pressed play it started the service and stop stopped it. Is there any way that when I press play or start for that windows service project I can have this same functionality. What I currently do is install them using installutil and I put a pre-processor command with System.Diagnostics.Debug.Launch() when I have a compilation variable defined and when I use the service manager it shows me the window to select the debugger. Still this method is somewhat cumbersome.
View 1 Replies
Jun 11, 2009
I have this code for a Windows service I am writing in .NET....However the TICK function never gets executed regardless of what interval I put in the tmrRun properties. What am I missing? I am sure its something stupid I am not seeing.
View 6 Replies
Apr 1, 2009
I'm trying to create a windows service that read from a database and process some retrieved results then send a notification emails for users on my active directory.I need to install the service on a server which is running 24/7, so it can capture the changes that occurred on a database hosted on it ( SQL Server 2005 - Mixed security mode ), now after installing the service ( it's Ok, and the build is Ok ) I tried to start it - because i set it to run manually - a msg popped said that (The $$$ service on local computer started and then stopped, Some services stop automatically if they have no work to do ...) Now in OnStart I'm initializing the connections ( 2 connections on the same server ) I stored their connection strings into the application settings, and after preparing the connections I'm starting a timer with interval of 10000 millisecond to read from database to get some important values to start the service.
[code]...
After that I will start another timer to run another script to check the main database to process and send emails, the service failed to start because on event viewer it shows this error :Service cannot be started. System.Data.SqlClient.SqlException: Login failed for user 'ICTSIMIS-01-ZKA$' (domainComputer Name$) So if it's a login problem to the server, what should I do to grant the access to the server even without a user login, becasue I already tried all possible Accounts I think it need to be (LocalSystem or LocalService)
View 2 Replies
Sep 11, 2009
It works on my own computer where I have visual studio installed. I install the exe file with installutil and the service works fine. But when I install it on another computer where only the framework is present, I still can install it with installutil BUT I can't start it. I get something along this Could not start the Search service on Local computer. Error 1053: The service did not respond to the start or control request in a timely fashion.[code]...
View 2 Replies
Nov 18, 2010
I cannot run Windows Services , I am getting error message "Cannot start Service from the command line or a debugger. A Windows Services must first be installed (using Installutil.exe) and then started with the ServerExplorer, Windows Services administrative tool or the NET START Command."
I have run the InstalluTil.exe and open the Visual Studio 2005 command prompt and run below command but still not working.
InstallUtil " D:\Khwathie\MyNewService\MyServ\MyServ\bin\Debug\MyService.exe".
View 2 Replies
Feb 2, 2012
I need to get the user input for where they want the files that will be produced by my windows service to be stored.
I was thinking that i could do this by reading in the user's input to a variable in the on start event of my service? this variable is then later used in my xml writer.
View 2 Replies
Oct 22, 2009
I have a service that needs to run several independent processes, my problem is that it only creates up to 23, from the 24th and so on the processes are not started and a DW20.EXE window error is displayed, it only says that the there has been an unhandled exception and that the proceess is going to be closed. Inside the process.start block there is no error so I guess it could be some limitation somewhere.
[Code]...
View 3 Replies
Apr 20, 2012
I have developed a windows services that Log On As "Local System" account with Statup Type "Automatic". I understand that windows services starts before user logins. But I want my service to start when ever user logs in.
View 3 Replies
Jan 17, 2012
I was able to programmatically launch a service on my development server from a workstation using the ServiceController class with no problems.
When I try to programmatically launch the service on my production server from my workstation, I get an access error which means I do not have rights to run the service with my logged in ID on the workstation.
My question is, is there a way to launch the service using different credentials? I do not see anywhere to input these credentials in the ServiceController class.
View 2 Replies
Sep 24, 2010
I created a service which monitors a few servers and file shares for exchange. Written in VB.NET 2.The service is installed and running fine(ish) but randomly and without any warning or entries in the event log it stops.Upon noticing it stops (the web front end that it generates stops working) we have to manage ther hosting server to attempt to start it again.If we simply try to restart it, it fails to start with a logon failure.
View 1 Replies
Mar 30, 2009
I get the following error in Vista while trying to start/stop a Windows Service that I created.
Cannot open ServiceName service on computer '.'.
The same code works for XP.
View 2 Replies
Nov 24, 2010
I have a Windows Service that needs to start other processes under a user context other than that used by the service. I've seen other posts related to this but have seen no resolutionI've tried many things and have been unsuccessful in starting the process from a Windows Service when a username, password is supplied. orking as it's a requirement of our system to do this and it worked fine until recently and only fails on Vista and Windows 7 (works on XP).
The following code is used to start the process.
Dim P As New Process
P.StartInfo.Domain = Domain
[code].....
View 2 Replies
Sep 2, 2010
I have a service projecwith a deployment project in a solution. The installation is successful, service runs ok. However each time after installation I will have to use ervices.msc to start up the software or restart the machine, any idea how I can start the services as soon a
View 3 Replies
Feb 28, 2011
I have made my application to start automaticly when windows start (registry ../currentversion/run/appname + path). In this mode the application start minimized and an little icon appear in the notification icon area. With this icon you can maximize the app or exit it.If you exit the app and start it again using the Menu (Start/programs etc) than the application start in minimized mode (and in this case I would like to have it in normal mode) because the setting autostart is still true.Is there a way you can detect when the application start when windows startup using the above registry or when people click on an icon in the programs menu (or desktop)?
View 2 Replies