I have the same problem this guy below has...... is this solution what I need to do? I noticed my service is currently running under the Network service account:
Page 1 of 1: [1] <http://vbcity.com/forums/post.asp?method=reply&tid=92621> Reply <http://vbcity.com/forums/post.asp?fid=37&method=topic> New Topic <javascript:loadPage('bookmarks.asp',%20'action=add&type=topic&id=92621',%20 true)> B'mark-It! <http://vbcity.com/forums/topic_print.asp?tid=92621> Print <javascript:submitaction('admin',%20'92621',%20'')> Admin 2/11/2005 2:12:36 PM # <http://vbcity.com/forums/goto.asp?show=topic&tid=92621> Accessing Windows Service from an Asp.Net page <http://vbcity.com/forums/post.asp?method=reply&tid=92621> Reply <http://vbcity.com/forums/post.asp?method=replyquotetopic&tid=92621> w/Quote <http://vbcity.com/forums/post.asp?method=editTopic&tid=92621> Edit jmiller808 (Junior Member) <http://vbcity.com/forums/profile.asp?id=jmiller808> Show this authors profile <http://vbcity.com/forums/mail.asp?id=jmiller808> Email the author of this post posts: 20 since: Dec 27, 2004 from: Denver, CO This topic is rated 1 point. i created a windows service in vb.net and it is running fine. i also had created a test application to work with the System.ServiceController class to see how that works for starting and stopping windows services. i would like add the ability to start and stop my service from an asp page. i have added the code to stop my service (pretty much copied it exactly how it was in the test app). when i click the button to start/stop the service i get an 'Access is denied error'. is there something i need to do in order to get access to the services on a machine through asp? 2/11/2005 2:59:20 PM #1 <http://vbcity.com/forums/goto.asp?show=reply&rid=288154> Re: Accessing Windows Service from an Asp.Net page <http://vbcity.com/forums/post.asp?method=reply&tid=92621> Reply <http://vbcity.com/forums/post.asp?method=replyquote&rid=288154> w/Quote <javascript:loadPage('bookmarks.asp',%20'action=add&type=reply&id=288154',%2 0true)> B'mark-It! <http://vbcity.com/forums/post.asp?method=edit&rid=288154> Edit <javascript:submitaction('delete',%20'288154',%20'the%20reply%20by%20betrl8t hanever%20posted%202/11/2005%202:59:20%20PM')> Del betrl8thanever (vbCity Leader) <http://vbcity.com/forums/profile.asp?id=betrl8thanever> Show this authors profile <http://vbcity.com/forums/mail.asp?id=betrl8thanever> Email the author of this post <http://www.zero-g-dev.com> Visit the authors home page posts: 4478 since: Dec 8, 2003 from: San Diego, CA You have to allow the ASPNET (The default account that ASP.NET applications run under) account administrative permissions for the machine that houses the Windows Service. Posting <http://www.vbcity.com/forums/topic.asp?tid=39382> Guidelines|vbCity <http://www.vbcity.com/forums/search.asp> Search Engine Free .NET Controls <http://www.zero-g-dev.com> -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Belcher Sent: Monday, August 08, 2005 5:59 PM To: [email protected] Subject: RE: [AspNetAnyQuestionIsOk] Windows ServiceAdministrationwithASP.NET ... ServiceController Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it. That looks like the object that needs to be used to do this. Here is a little more on that from MS themselves http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/ frlrfsystemserviceprocessservicecontrollermemberstopic.asp Heres a little more: Visual Basic and Visual C# Concepts Creating ServiceController Component Instances You can use the ServiceController component to connect to and control the behavior of existing services. When you create an instance of the ServiceController class, you set its properties so that it interacts with a specific Windows service. You can then use the class to start, stop, and otherwise manipulate the service. You will most likely use a ServiceController in an administrative capacity. For example, you might create a Windows or ASP .NET Web application that sends custom commands to a service via a ServiceController component instance. This would be useful because the Services Control Manager does not support custom commands. There are several ways you can create an instance of the ServiceController component: * You can drag an instance of the ServiceController component from the Components tab of the Toolbox to a form or other designer. * You can add a ServiceController component to your designer from Server Explorer * You can create an instance of the ServiceController class in code. After you create an instance of ServiceController, you must set two properties on it to identify the service with which it interacts: the machine name and the name of the service you want to control. Note By default, MachineName is set to the local computer, so you do not need to change it unless you want to set the component instance to point to another computer. To create and configure a ServiceController component from Server Explorer 1. In Server Explorer, add the server you want if it is not already listed. For more information, see Accessing <http://msdn.microsoft.com/library/en-us/vsintro7/html/vbtskAccessingServerE xplorer.asp> and Initializing Server Explorer. Note The Servers node of Server Explorer is not available in the Standard Edition of Visual Basic and Visual C# .NET. For more information, see Visual <http://msdn.microsoft.com/library/en-us/vbcon/html/vbgrfvisualbasicstandard editionfeatures.asp> Basic Standard Edition Features or Visual <http://msdn.microsoft.com/library/en-us/cscon/html/vcgrfvisualcsstandardedi tionfeatures.asp> C# Standard Edition Features. 2. Expand the Services node, and then locate the service on which you want to perform administrative tasks. 3. Right-click the name of the service, and click Add to Designer. A ServiceController component appears in your project, configured to interact with the selected service. To create and configure a ServiceController component from the Toolbox 1. Access the Components tab of the Toolbox. 2. Select the ServiceController icon and drag it to the designer surface for your form or component. 3. Set the following properties. Property Setting MachineName The name of the computer on which the service exists, or "." for the local computer. ServiceName The name of the service with which you want to interact. 4. Tip You can use Server Explorer to see what the ServiceName should be set to for any given service. Select the service in which you're interested in Server Explorer, and the ServiceName for it appears in the Properties window. To programmatically create and configure a ServiceController component 1. Create an instance of the ServiceController class in your code. 2. Set the MachineName and ServiceName properties to indicate the service you want to control. The following example shows how to create a ServiceController component that interacts with the IIS Admin service on the local computer. The component then queries the service associated with the controller to determine if it can accept Stop commands, and if so, issues the command. This example is part of a Windows project in which a form with various buttons is used to start, stop, and otherwise manipulate the service. Each time a button is clicked, the condition is evaluated and status information is displayed in a label control. Note Before these samples will run, you must add a reference to System and System.ServiceProcess DLLs and include an Imports or Using statement for the both namespaces. ' Visual Basic Sub Main() Dim myController As _ New System.ServiceProcess.ServiceController("IISAdmin") If myController.CanStop Then Debug.WriteLine(myController.ServiceName & " can be stopped.") Else Debug.WriteLine(myController.ServiceName & " cannot stop.") End If End Sub // C# public static void Main(string[] args) { System.ServiceProcess.ServiceController myController = new System.ServiceProcess.ServiceController("IISAdmin"); if (myController.CanStop) { System.Diagnostics.Debug.WriteLine( myController.DisplayName + " can be stopped."); } else { System.Diagnostics.Debug.WriteLine( myController.DisplayName + " cannot stop."); } } See Also Introduction <http://msdn.microsoft.com/library/en-us/vbcon/html/vbconintroductiontoservi cecontrollercomponent.asp> to Communicating with Existing Services | Performing <http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskperformingadministr ativetasksonservices.asp> Administrative Tasks on Services | Retrieving <http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskretrievinglistsofse rvices.asp> Lists of Services -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of David Renz Sent: Monday, August 08, 2005 5:17 PM To: [email protected] Subject: RE: [AspNetAnyQuestionIsOk] Windows ServiceAdministrationwithASP.NET ... you piqued my interest. here are some other things i found .. most not so useful maybe ... some i hope though. http://aspalliance.com/340 http://www.codeproject.com/dotnet/simplewindowsservice.asp bottom has some info http://builder.com.com/5100-6371-5784748-2.html >>> [EMAIL PROTECTED] 08/08/2005 2:02:53 PM >>> System.Diagnostics.Process.Start(sRootPath & "bat\" & sBatFile) http://blogs.msdn.com/vbfaq/archive/2004/05/30/144573.aspx >>> [EMAIL PROTECTED] 08/08/2005 1:59:01 PM >>> To give you a backround on what I am doing. I setup a counter strike source server as a server. This is a game server that people connect to and play etc. Sometimes you will want to stop the server to update files. Then of course start it. Other times if there is a crash or you just want to clear it up you can restart it. I created a new service and it is listed in the services mmc. I also tested it out by running half life 2 CSS and joined the server and ran around works great. There is no console showing though and im not sure how to get that to work but that's another issue. I understand that there is a way to access these services and control them via asp.net. I amnot sure how and would like to see a VB.net example if there is one out there. The batch file thing I thought about also and would need that for running a server update. As a second question david on your code below how would I execute the batch file from a aspx page? If a page has a AUTO PATCH SERVER button then what would you put in the code behind to runt hat script? Thanks for the help............ -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of David Renz Sent: Monday, August 08, 2005 4:51 PM To: [email protected] Subject: Re: [AspNetAnyQuestionIsOk] Windows Service Administrationwith ASP.NET ... Couldn't you write a batch file using Net commands (IE: NET STOP or NET START, etc). then execute the batch file from the code ... provided you had the proper permissions? batch file like so: net stop "Simple Mail Transport Protocol (SMTP)" net stop "World Wide Web Publishing service" net stop "FTP Publishing Service" net stop "IIS Admin Service" net start "IIS Admin Service" net start "FTP Publishing Service" net start "World Wide Web Publishing service" net start "Simple Mail Transport Protocol (SMTP)" echo "WEB is up and running" >>> [EMAIL PROTECTED] 08/08/2005 1:46:54 PM >>> I have looked on google for information and found a couple but they are all in C#. What I want to do is to be able to STOP / START / RESTART a windows server on a server from and asp.net page. I am using VB.net. STOP BUTTON Stops service START BUTTON Starts Service RESTART BUTTON Restarts Service That's what is on my webform.............. Just need to create the code to do it........................ Yahoo! Groups Links [Non-text portions of this message have been removed] Yahoo! Groups Links Yahoo! Groups Links [Non-text portions of this message have been removed] Yahoo! Groups Links [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12he38hoo/M=362329.6886308.7839368.1510227 /D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123543010/A=2894321/R=0/SIG=11dvsfulr /*http://youthnoise.com/page.php?page_id=1992 ">Fair play? Video games influencing politics. Click and talk back!</a>.</font> --------------------------------------------------------------------~-> Yahoo! Groups Links http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ [EMAIL PROTECTED] http://docs.yahoo.com/info/terms/ [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h50c4n3/M=362131.6882499.7825260.1510227 /D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123545568/A=2889191/R=0/SIG=10r90krvo /*http://www.thebeehive.org ">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life - brought to you by One Economy</a>.</font> --------------------------------------------------------------------~-> Yahoo! Groups Links http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ [EMAIL PROTECTED] http://docs.yahoo.com/info/terms/ [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h1683iq/M=362329.6886308.7839368.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123557406/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992 ">Fair play? Video games influencing politics. Click and talk back!</a>.</font> --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
