Hudson build server install as a windows service error - jenkins

Problem
I am trying to install hudson build server on a windows server through remote desktop connection. I path to the Hudson folder in the C:\Hudson. The Hudson directory contains a folder called Home and the hudson.war file.
I tried to start it up using the following commands:
set JAVA_HOME=C:\Java\jdk1.6.0_20
set HUDSON_HOME=C:\Hudson\Home
java -jar C:\Hudson\hudson.war
Then I can navigate to http://localhost:8080 in internet explorer.
Question
When I try to use the Install as Windows Service function on the web interface, I get this error:
Installing a service
[Home] $ C:\Hudson\Home\hudson.exe install
WMI.WmiException: AccessDenied
at WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
at WMI.Win32ServicesProxy.Create(String , String , String , ServiceType , ErrorControl , StartMode , Boolean , String[] )
at winsw.WrapperService.Run(String[] args)
at winsw.WrapperService.Main(String[] args)`
Why can't I install as a windows service and how can I fix this issue?

Answer
Found the solution.
When running the commands you need to open the command prompt by right clicking and selecting "run as administrator".

On the windows command prompt, execute: sc delete hudson
and for jenkins user, execute: sc delete jenkins
and then run install windows as a service.
Hope it helps :)

Try turning off User Account Control; that's what fixed it for me. Start > Run > UAC, then drag the dial to the lowest setting: "Never notify". May require a reboot.

Related

Windows is not recognizing serverless as internal or external command

I wanted to install serverless in my windows 7 machine.My npm version is 6.1.0.
I used the command
npm install -g serverless
C:\Users\ADMIN\AppData\Roaming\npm\serverless -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\slss -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\sls -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
> spawn-sync#1.0.15 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\node_modules\spawn-sync
> node postinstall
> serverless#1.30.1 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless
> node ./scripts/postinstall.js
+ serverless#1.30.1
added 351 packages from 269 contributors in 154.064s
But when I type serverless in command prompt, it tells me
'serverless' is not recognized as an internal or external command,
operable program or batch file.
I had the same issue and I believe you are missing the npm path from your environment variables.
Go to Windows search and type:
"Edit the system environment variables"
(at least this is how you can find the Environment Variables in Windows 10).
Go to Advanced tab and click on Environment Variables.
Select Path from the User Variables and click Edit.
Click New and provide the following:
C:\Users[USER_NAME]\AppData\Roaming\npm\
or whatever is the path that you have installed npm - just change the [USER_NAME] with your username account.
Else you could navigate to the path above and execute "serverless" from inside that path.
Hope that helps :)
Try make use of npx
Example:
npx sls deploy
I had the same issue. In my Windows 10 system, I wanted to install serverless under Git Bash.
I was able to install serverless with the normal account just fine, but then the serverless command was not found (even after closing Git Bash and launching it again). After doing the same steps using Administrator privileges, everything worked fine even using the normal user account. Perhaps this will help someone.
^^Adding both environment paths, to npm and serverless/bin, worked for me. Same issue. Windows 10, trying to start a Serverless project after it seemingly installed correctly.
Going to it from /npm also worked, but the adding both environment paths was the permanent solution by #Suday Ghosh
Go to System Window (Control Panel\System and Security\System);
Click "Advanced System Settings"
Click "Environment Variables"
Select "Path" variables and click "Edit" Button
Under "Edit environment variable" window, Click "New" Button
Provide the following paths separately:
C:\Users[USER_NAME]\AppData\Roaming\npm\
AND
C:\Users[USER_NAME]\AppData\Roaming\npm\node_modules\serverless\bin
Happy !!!!!!

Build Agent is Offline

I m using TFS 2015, I saw that my build Agent is Offline :
I launch the VsoWorker.exe to see the logs and understand the error, Here is what I get but I found nothing from the internet : Any Idea please ?
16:07:57.649004 Sending trace output to log files: C:\Users\Administrator\Downloads\agent\_diag
16:07:57.649004 vsoWorker.exe was run with the following command line:
"C:\Users\Administrator\Downloads\agent\Agent\Worker\VsoWorker.exe"
16:07:57.649004 VsoWorker.Main(): Create AgentLogger
16:07:57.649980 VsoWorker.Main(): Parse command line
16:07:57.655848 ---------------------------------------------------------------------------
16:07:57.657635 System.Exception: The /name command line option is required and must have a value.
16:07:57.657635 at VsoWorker.CommandLine.ValidateCommandLine()
16:07:57.657635 at VsoWorker.CommandLine..ctor(String[] args)
16:07:57.657635 at VsoWorker.Program.Main(String[] args)
16:07:57.657635 at VsoWorker.CommandLine.ValidateCommandLine()
16:07:57.657635 at VsoWorker.CommandLine..ctor(String[] args)
16:07:57.657635 at VsoWorker.Program.Main(String[] args)
16:07:57.657635 ---------------------------------------------------------------------------
16:07:57.658878 BaseLogger.Dispose()
When you install the Build Agent you are instructed to make a C:\Agents folder:
If you have not first configured the Build Agent, open Powershell and run this command:
PS C:\agent> .\config.cmd
In the config setup there is an option to run the Build Agent as a Window Service. This way you don't need to start it each time the machine reboots.
If you've found the BuildAgent has been installed but is offline, it's probably not been configured to run as a Service
and you will need execute this command to run the Build Agent or just double click the file:
PS C:\agent> .\run.cmd
This should bring the Build Agent online.
Note: The 1st time I tried this and it worked. The second time it didn't and I ran the C:\agent\bin\Agent.Listener.exe instead. I tried a 3rd time running the run.cmd and this time I waited a minute or 2 and it worked:
Note: You're better off making the agent run as a Service, this way you only need to run the config.cmd once and never need to run the run.cmd.
Make sure you deploy the Windows build agent by exactly following this article.
Make sure the account that the agent is run under is in the "Agent Pool Service Account" role.
Try to change a domain account which is a member of the Build Agent Service Accounts group and belongs to "Agent Pool Service Account" role, to see whether the agent would work or not.
Don't run the VsoWorker.exe application directly. Use the RunAgent.cmd file.

Running Jenkins on Tomcat Fail applicaton at context path /jenkins could not be started

For a few days I am trying to set Jenkins on Tomcat7 without any result... I read many tutorials and I could not find any help...
I set a virtual system on VirtualBox -> Ubuntu 12.04.04
Using apt-get I installed tomcat7, and then Jenkins.
While using them separately by usingcommad sudo service tomcat7 start or sudo service jenkins start both services starts and are visable on my localhost.
However, when I copied jenkins.war to /var/lib/tomcat7/webapps I cannot run it via tomcat.
I have set JENKINS_HOME as /var/lib/jenkins.
In the folder /usr/share/tomcat7 i run these commands: sudo mkdir .jenkins | sudo chown tomcat7:nogroup .jenkins
And from localhost:8080/manager jenkins is viable:
When I try localhost:8080/jenkins as tutorials says I get en error message:
I really have no idea what am I doing wrong...
What else may I try to make it work?
I had the same issue. Please check Java compatibility version with the "Jenkins.war" file. I used Java 8 for Jenkins version 2.107.1.
I would suggest to shutdown restart the tomcat server. As it should be able to read the .war file. Hence, you will go through additional setup.
Check the version of your jenkins.war file
Check the compatibe java version for hat jenkins version in web
Download that version of java and define system environment variables path for JAVA_HOME
Open "Monitor tomcat" in that JAVA define the path of jvm.dll
example C:\Program Files\Java\jdk-11.0.16\bin\server\jvm.dll
This picture shows how to run in windows:
Please check your JRE path, as I face a similar issue where JRE_HOME was incorrectly set
JRE_HOME=/usr/jdk/jdk1.6.0_21,
It started working when I correct it to latest JRE version
JRE_HOME=/usr/jdk/jdk1.7.0_09/jre.

Install a Windows service using a Windows command prompt?

I want to install a Windows service using a Windows command prompt (not the Visual Studio command prompt).
How do I do this?
Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"
Regarding a comment, for 64bit apps, use below:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe
Nothing wrong with SC Create command.
Just you need to know the correct args :
SC CREATE "MySVC" binpath= "D:\Me\Services\MySVC\MySVC.exe"
If the directory's name has a space like c:\program files\abc 123, then you must use double quotes around the path.
installutil.exe "c:\program files\abc 123\myservice.exe"
It makes things much easier if you set up a bat file like following,
e.g. To install a service, create a "myserviceinstaller.bat" and "Run as Administrator"
#echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
installutil.exe "C:\Services\myservice.exe"
if ERRORLEVEL 1 goto error
exit
:error
echo There was a problem
pause
to uninstall service,
Just add a -u to the installutil command.
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "C:\Services\myservice.exe"
Perform the following:
Start up the command prompt (CMD) with administrator rights.
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe [your windows service path to exe]
Press return and that's that!
It's important to open with administrator rights otherwise you may find errors that come up that don't make sense. If you get any, check you've opened it with admin rights first!
To open with admin rights, right click 'Command Prompt' and select 'Run as administrator'.
Source:
http://coderamblings.wordpress.com/2012/07/24/how-to-install-a-windows-service-using-the-command-prompt/
Install Service:-
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"
"C:\Services\myservice.exe"
UnInstall Sevice:-
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" -u "C:\Services\myservice.Service.exe"
Create a *.bat file beside of your windows service exe file for installing with the following context:
CLS
ECHO Installing My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%~d0%~p0\YourWindowsServiceExeName.exe"
Create a *.bat file beside of your windows service exe file for uninstalling with the following context:
CLS
ECHO Uninstalling My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "%~d0%~p0\YourWindowsServiceExeName.exe"
Run each of bat file as Admin to install or uninstall your windows service.
I must add one more point in this thread. To install/uninstall 64-bit version of assemblies one should use 64-bit version of tool. To install a service, the command should be:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe"
"C:\YourFolder\YourService.exe"
and to uninstall the command should be:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" -u
"C:\YourFolder\YourService.exe"
Run Windows Command Prompt as Administrator
paste this code: cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ to go to folder
edit and run this too: installutil C:\ProjectFolder\bin\Debug\MyProject.exe
Note: To uninstall: installutil /u C:\ProjectFolder\bin\Debug\MyProject.exe
open Developer command prompt as Admin and navigate to
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
Now use path where is your .exe there
InstallUtil "D:\backup\WindowsService\WindowsService1\WindowsService1\obj\Debug\TestService.exe"
Open Visual studio and select new project by selecting Windows Service template in Windows Desktop tab. Than copy following code into your service_name.cs file.
using System.Diagnostics;
using System.ServiceProcess;
namespace TimerService
{
public partial class Timer_Service : ServiceBase
{
public Timer_Service()
{
InitializeComponent();
}
static void Main()
{
if (System.Diagnostics.Debugger.IsAttached)
{
Timer_Service service = new Timer_Service();
service.OnStart(null);
}
else
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Timer_Service()
};
ServiceBase.Run(ServicesToRun);
}
}
protected override void OnStart(string[] args)
{
EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service start successfully." });
}
protected override void OnStop()
{
EventLog.WriteEvent("Timer_Service", new EventInstance(0, 0, EventLogEntryType.Information), new string[] { "Service stop successfully." });
}
}
}
Right-Click on service_name.cs file and open designer of service. than right-click and select Add Installer. than right-click on serviceProcessInstaller1 and change its property value of Account from User to Local System.
Remove static void main method from Program.cs file.
Than save and Build your project.
NOTE: goto bin\Ddebug folder of your project folder. Than open Properties of your service_name.exe file. Than goto Compatibility tab. Than click on Change Settings For All Users.
Select option Run this program as an administrator.
Now, You have to open CommandPromt as Administrator.
After open, set directory to where your InstallUtil.exe file is placed.
for ex: C:\Windows\Microsoft.NET\Framework64\v4.0.30319.
now write the following command:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe -i C:\TimerService\TimerService\bin\Debug\TimerService.exe
Note: -i is for install he service and -u for Unsinstall.
after -i set the write the path where you want to install your service.
now write the command in CommandPromt as follows:
C:\TimerService\TimerService\bin\Debug>net start service_name
Note: use stop for stop the Service.
Now, open ViewEventLog.exe. Select Windows Logs>Application. There you can check your Service's log by start and stop the service.
the following code , install and uninstall the Service,
Open the command prompt and run the program as an administrator and fire the below command and press enter.
Syntax
To Install
C:\windows\microsoft.net\framework\v4.0.30319>InstallUtil.exe + Your copied path + \your service name + .exe
eg :Our Path
InstallUtil.exe C:\MyFirstService\bin\Debug\MyFirstService.exe
To uninstall
C:\windows\microsoft.net\framework\v4.0.30319>InstallUtil.exe -u + Your copied path + \your service name + .exe
eg : Our path InstallUtil.exe -u C:\MyFirstService\bin\Debug\MyFirstService.exe
for more help you can see the following link: sample program
If you are using Powershell and you want to install .NET service you can use Install-Service module. It is a wrapper for InstalUtil tool.
It exposes 3 commands
Install-Service - invokesĀ InstallUtil.exe pathToExecutable command
Install-ServiceIfNotInstalled - first it checks if service is
installed if not perform the method Install-Service
Uninstall-Service- it uninstalls service. ServiceName of path to executable can be used.
Code to this module can be viewed here
start up the command prompt (CMD) with administrator rights.
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe [your windows service path to exe]
Press return
1.From the Start menu, select the Visual Studio directory, then select Developer Command Prompt for VS .
2.The Developer Command Prompt for Visual Studio appears.
3.Access the directory where your project's compiled executable file is located.
4.Run InstallUtil.exe from the command prompt with your project's executable as a parameter
when your assembly version and your Visual studio project Biuld setting on dot net 2 or 4 install with same version.
install service with installutil that same version
if build in dot net 4
Type c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe
if build in dot net 2
Type c:\windows\microsoft.net\framework\v2.0.11319\installutil.exe
Follow these steps when deploying the Windows Service, don't lose time:
Run command prompt by the Admin right
Insure about release mode when compilling in your IDE
Give a type to your project installer on design view
Select authentication type in accordance the case
Insure about software dependencies: If you are using a certificate install it correctly
Go your console write this:
C:\Windows\Microsoft.NET\Framework\yourRecentVersion\installutil.exe c:\yourservice.exe
there is a hidden -i argument before the exe path -i c:\ you can use -u for uninstallling
Look your .exe path to seem log file. You can use event viewer to observing in the feature
you can do using command prompt and write:
C:\windows\microsoft.net\framework\v4.0.30319\InstallUtil.exe -i ".EXE file of window service"
You can use InstallUtil to install any windows service.
1: C:\Windows\Microsoft.NET\Framework64\v4.0.30319 in command prompt running as Adminstrator.
2: Copy the Exe path and type InstallUtil.exe "your exe path"
and hit enter.
If you want visual elaboration. Goto below link.
It helped me alot.
https://youtu.be/yrdyYxzI7SE
You should open command prompt, go to
C:\windows\microsoft.net\framework\v4.0.30319\InstallUtil.exe -i ".EXE file of window service"
Open command prompt as administrator, go to your Folder where your .exe resides.
To Install Exe as service
D:\YourFolderName\YourExeName /i
To uninstall use /u.

How can I delete a service in Windows?

I have a couple old services that I want to completely uninstall. How can I do this?
Use the SC command, like this (you need to be on a command prompt to execute the commands in this post):
SC STOP shortservicename
SC DELETE shortservicename
Note: You need to run the command prompt as an administrator, not just logged in as the administrator, but also with administrative rights. If you get errors above about not having the necessary access rights to stop and/or delete the service, run the command prompt as an administrator. You can do this by searching for the command prompt on your start menu and then right-clicking and selecting "Run as administrator". Note to PowerShell users: sc is aliased to set-content. So sc delete service will actually create a file called delete with the content service. To do this in Powershell, use sc.exe delete service instead
If you need to find the short service name of a service, use the following command to generate a text file containing a list of services and their statuses:
SC QUERY state= all >"C:\Service List.txt"
For a more concise list, execute this command:
SC QUERY state= all | FIND "_NAME"
The short service name will be listed just above the display name, like this:
SERVICE_NAME: MyService
DISPLAY_NAME: My Special Service
And thus to delete that service:
SC STOP MyService
SC DELETE MyService
Click Start | Run and type regedit in the Open: line. Click OK.
Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
Scroll down the left pane, locate the service name, right click it and select Delete.
Reboot the system.
As described above I executed:
sc delete ServiceName
However this didn't work as I was executing it from PowerShell.
When using PowerShell you must specify the full path to sc.exe because PowerShell has a default alias for sc assigning it to Set-Content. Since it's a valid command it doesn't actually show an error message.
To resolve this I executed it as follows:
C:\Windows\System32\sc.exe delete ServiceName
Use services.msc or (Start > Control Panel > Administrative Tools > Services) to find the service in question. Double-click to see the service name and the path to the executable.
Check the exe version information for a clue as to the owner of the service, and use Add/Remove programs to do a clean uninstall if possible.
Failing that, from the command prompt:
sc stop servicexyz
sc delete servicexyz
No restart should be required.
SC DELETE "service name"
Run the command on cmd as Administrator otherwise you will get this error :-
openservice failed 5 access is denied
If you have Windows Vista or above please run this from a command prompt as Administrator:
sc delete [your service name as shown in service.msc e.g moneytransfer]
For example: sc delete moneytransfer
Delete the folder C:\Program Files\BBRTL\moneytransfer\
Find moneytransfer registry keys and delete them:
HKEY_CLASSES_ROOT\Installer\Products\
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\
HKEY_LOCAL_MACHINE\System\CurrentControlSet002\Services\
HKEY_LOCAL_MACHINE\System\CurrentControlSet002\Services\EventLog\
HKEY_LOCAL_MACHINE\Software\Classes\Installer\Assemblies\ [remove .exe references]
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Folders
These steps have been tested on Windows XP, Windows 7, Windows Vista, Windows Server 2003, and Windows Server 2008.
We can do it in two different ways
Remove Windows Service via Registry
Its very easy to remove a service from registry if you know the right path. Here is how I did that:
Run Regedit or Regedt32
Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"
Look for the service that you want delete and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).
Delete Windows Service via Command Window
Alternatively, you can also use command prompt and delete a service using following command:
sc delete
You can also create service by using following command
sc create "MorganTechService" binpath= "C:\Program Files\MorganTechSPace\myservice.exe"
Note: You may have to reboot the system to get the list updated in service manager.
If they are .NET created services you can use the installutil.exe with the /u switch
its in the .net framework folder like
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
This did the job for me on Windows 10:
start the cmd.exe as admin
run SC DELETE "com.docker.service"
reinstall docker
Here is a vbs script that was passed down to me:
Set servicelist = GetObject("winmgmts:").InstancesOf ("Win32_Service")
for each service in servicelist
sname = lcase(service.name)
If sname = "NameOfMyService" Then
msgbox(sname)
service.delete ' the internal name of your service
end if
next
sc delete name
Before removing the service you should review the dependencies.
You can check it:
Open services.msc and find the service name, switch to the "Dependencies" tab.
Source: http://www.sysadmit.com/2016/03/windows-eliminar-un-servicio.html
You can use my small service list editor utility Service Manager
You can choose any service > Modify > Delete. Method works immediately, no reboot required.
Executable file: [Download]
Source code: [Download]
Blog post: [BlogLink]
Service editor class: WinServiceUtils.cs
For me my service that I created had to be uninstalled in Control Panel > Programs and Features

Resources