Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
- Pick a username
- Email Address
- Password
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Use sc command under CMD to delete the tomcat service and report openservice failed 1060 error
Reason: The status of the Tomcat service in the service is disabled. If the status is changed to automatic, sc DELETE Tomcat can be used
Note: Although the service name is Apache Tomcat, you do not need to add Apache when removing the Tomcat service
Conclusion:
There are two ways to delete Windows services:
Option 1: start — run — cmd.exe with the Windows command
, then type sc to see it. The method is simple:
sc delete “Service name” (if there is a space in the Service name, you need to put quotes around it)
as above: sc delete Service
open the registry editor and find the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services generally the service will display a key with the same name here, just delete the key directly.
Read More:
I would like to control a Service (e.g. WinRM) using Powershell via the WinAPI. (Just for an exercise).
After running the script, I get a handle to the service control manager database. However, I dont get a handle of the «WinRM»-Service. I only get the Error-Code 1060 (The specified service does not exist as an installed service.) after executing the OpenServiceA-Function.
Service.ps1
$loadAdvapi32 = @"
public struct LPSERVICE_STATUS {
public uint dwServiceType;
public uint dwCurrentState;
public uint dwControlsAccepted;
public uint dwWin32ExitCode;
public uint dwServiceSpecificExitCode;
public uint dwCheckPoint;
public uint dwWaitHint;
}
[DllImport("Advapi32.dll", CharSet=CharSet.Auto)]
public static extern
IntPtr OpenSCManager(string lpMachineName,
string lpDatabaseName,
uint dwDesiredAccess);
[DllImport("Advapi32.dll", CharSet=CharSet.Auto)]
public static extern
IntPtr OpenServiceA(IntPtr hSCManager,
string lpServiceName,
uint dwDesiredAccess);
[DllImport("Advapi32.dll", CharSet=CharSet.Auto)]
public static extern
bool ControlService(IntPtr hService,
uint dwControl,
out LPSERVICE_STATUS lpServiceStatus);
"@
$loadKernel32 = @"
[DllImport("Kernel32.dll", CharSet=CharSet.Auto)]
public static extern
int GetLastError();
"@
Add-Type -MemberDefinition $loadAdvapi32 -Name 'Advapi32' -Namespace 'Win32';
Add-Type -MemberDefinition $loadKernel32 -Name 'Kernel32' -Namespace 'Win32';
$lpMachineName = [NullString]::Value;
$lpDatabaseName = [NullString]::Value;
# https://learn.microsoft.com/en-us/windows/win32/services/service-security-and-access-rights
$SC_MANAGER_ALL_ACCESS = 0xF003F;
$SERVICE_ALL_ACCESS = 0xF01FF;
$hSCManager = [Win32.Advapi32]::OpenSCManager($lpMachineName, $lpDatabaseName, $SC_MANAGER_ALL_ACCESS);
[Win32.Kernel32]::GetLastError()
$schService = [Win32.Advapi32]::OpenServiceA($hSCManager, "WinRM", $SERVICE_ALL_ACCESS);
[Win32.Kernel32]::GetLastError()
Output
PS C:\Windows\system32> C:\Service.ps1
0
1060
I already tried/checked:
- WinRM-Service exists and is installed
- Running the script in an elevated Powershell
- Checked if the Name of the Service is correct
- Remove From My Forums
-
Question
-
Hi there,
I have cleared the temp folder on the server where my windows service is running and when i try and use sc.exe \\SERVERNAME STOP SERVICENAME i get the 1060 error.
By the way i am using command line to stop the service. I am also using the PSEXEC tool to stop the service on the remote server.
Here is my code:
psexec -accepteula \\THESERVER -e -s -u DOMAIN\testuser -p thepassword7 sc.exe \\THESERVER STOP ParisConnect;
The error i get is this:
PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich Sysinternals - www.sysinternals.com [SC] OpenService FAILED 1060: The specified service does not exist as an installed service sc.exe exited on THESERVER with error code 1060.
I tried invoking a cmd.exe on the remote server to test connectivity and this worked. I was able to start the cmd.exe process.
Any ideas why this error could be happening? The account i am currently using is part of the Administrators group on the server.
Kind Regards,
-
Edited by
Wednesday, May 14, 2014 10:51 AM
-
Moved by
Anna Cc
Thursday, May 15, 2014 9:04 AM
-
Edited by
Answers
-
you actually don’t need to do both psexec and sc
sc already supports doing remote service commands, it’s the net command that doesn’t support remote access
-
Marked as answer by
Vivian_Wang
Wednesday, June 4, 2014 2:51 AM
-
Marked as answer by
-
was the service running?
- ERROR_SERVICE_DOES_NOT_EXIST
- 1060 (0x424)
-
The specified service does not exist as an installed service.
maybe you should query first whether the service is running or not, if the service runs then stop it.
Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
IT Stuff Quick Bytes-
Marked as answer by
Vivian_Wang
Wednesday, June 4, 2014 2:51 AM
- Remove From My Forums
-
Question
-
When trying to install NET Framwork 3.5, i get the error 1060, which is
The specified service does not exist as an installed service.
How can i fix this?????
i’m running Windows Vista Home Premium 32-Bit.
thanks.
Answers
-
Hi Robo,
Never mind. Now I could access your Public folder. Take it easy.
I found an error from your log files:
[01/21/09,11:44:38] Microsoft .NET Framework 2.0SP1 (CBS): C:\Windows\system32\WUSA.exe exited with return value 1060
[01/21/09,11:44:38] Microsoft .NET Framework 2.0SP1 (CBS): ***ERRORLOG EVENT*** : Error: Installation failed for component Microsoft .NET Framework 2.0SP1 (CBS). MSI returned error code 1060This error happened when .Net Framework 3.5 tried to upgrade .Net Framework 2.0 to SP1. Wusa.exe is Windows Update Stand-alone Installer in Windows Vista and in Windows Server 2008. So your problem could be caused by Windows Update.
For more information of Wusa.exe, see: http://support.microsoft.com/kb/934307Please make sure that Windows Update has been turned on. If not, please turn on it, install the latest updates from the Windows Update Site and try to reinstall .Net Framework 3.5.
If you still have any concern about your issue, please feel free to let me know.
Thanks
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Marked as answer by
Tuesday, January 27, 2009 1:33 AM
-
Marked as answer by