jimbona27
asked on
service control permission problem as the same code works in vb.net application
hi,
I have the following code for my webmethod to control the Print Spooler service although Im getting a webby permission problem because copying the code into a vb.net application works perfectly.
Any ideas what permissions I need to set? Many thanks
<WebMethod()> _
Public Function test() As String
Dim sc As ServiceController
Try
For Each sc In ServiceController.GetServi ces()
If sc.DisplayName.Equals("Pri nt Spooler") Then Exit For
Next
If sc.Status = ServiceControllerStatus.St opped Then
' Start the service if its stopped
Try
' Start the service, and wait until its status is "Running".
sc.Start()
sc.WaitForStatus(ServiceCo ntrollerSt atus.Runni ng)
Catch ex As Exception
Return "11111 " & ex.Message
End Try
End If
Catch ex As Exception
Return "22222 " & ex.Message
End Try
End Function
I have the following code for my webmethod to control the Print Spooler service although Im getting a webby permission problem because copying the code into a vb.net application works perfectly.
Any ideas what permissions I need to set? Many thanks
<WebMethod()> _
Public Function test() As String
Dim sc As ServiceController
Try
For Each sc In ServiceController.GetServi
If sc.DisplayName.Equals("Pri
Next
If sc.Status = ServiceControllerStatus.St
' Start the service if its stopped
Try
' Start the service, and wait until its status is "Running".
sc.Start()
sc.WaitForStatus(ServiceCo
Catch ex As Exception
Return "11111 " & ex.Message
End Try
End If
Catch ex As Exception
Return "22222 " & ex.Message
End Try
End Function
ASKER
thanks, im not sure about the permissions but I know the print spooler service is running as a local system account.
Check your service in the Services Console. Go into it's properties and you will see under whch account it is running. Change this to Local System and you should have more luck.
If not change it to your logon details and try again.
Else show us the error message because it might be a permissions problem somewhere else.
If not change it to your logon details and try again.
Else show us the error message because it might be a permissions problem somewhere else.
ASKER
how can I setup the permission so it should work when depolying the site on another server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
will do.
can you inform me how to move a website to another location, i.e. copy the files onto another server?
then I'll test whether the impersonation works (after reading the url)
thanks,
can you inform me how to move a website to another location, i.e. copy the files onto another server?
then I'll test whether the impersonation works (after reading the url)
thanks,
In asp.net v1.1 you just build the site for release and then copy the entire structure (excluding all .vb or .cs files) to the server.
In asp.net v2 you need to publish your site to a local folder and then copy the structure from there.
In asp.net v2 you need to publish your site to a local folder and then copy the structure from there.
I generally setup a service user which has the permissions required to access the file system and event logs and such.
An exact error message always helps :)