24

I am trying to install Jenkins slave service after starting the slave via web start. I get the following error when it tries to install on windows 10 and windows 8.1.

[JenkinsWorkDirectory]$ c:\JenkinsWorkDirectory\jenkins-slave.exe install
WMI.WmiException:AccessDenied
at WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
at WMI.Win32ServicesProxy.Create(String, String, String, ServiceType, ErrorControl, StartMode, Boolean, String, String, String[])
at winsw.WrapperService.Run(String[]_args,ServiceDescriptor descriptor)
at winsw.WrapperService.Main(String[]args).

I can install the slave service without any issue on win 7. Any idea why is this happening or is it some limitation of Jenkins or am i missing some dependency?

My jenkins version is 1.655 and using chrome browser when installing. Jenkins master is running on windows 7. Thanks, Daniel

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
zalimgandhera
  • 747
  • 1
  • 9
  • 23
  • Permissions issue? If you plan to have access to a Desktop, i.e. for gui tests, i suggest to use the jnlp method though. – Dominik Gebhart Apr 08 '16 at 21:27
  • Thanks I tried it but TestComplete plugin says to start is as service. In that way i dont need to have an active user session on the slave machine. – zalimgandhera Apr 18 '16 at 09:47
  • Good luck, i tried it and did not get it to work as service without an active user session. Screenshots would stay black. – Dominik Gebhart Apr 18 '16 at 12:13
  • Could you please elaborate on the screenshot part? I tried it on windows 7 slave working as service and got results fine without any issue. – zalimgandhera Apr 19 '16 at 09:21
  • For GUI tests your jenkins/testcomplete needs access to a desktop. A system service doesnt have access, however you can change some settings to run as a user and allow desktop interaction, but this didnt work as exspected for me. I added a job which executes a screenshot program to test access. Only got it working with setting autologin for a user and connecting the windows slave via jnlp. – Dominik Gebhart Apr 19 '16 at 11:44
  • It appears the jenkins-slave .net project that was created is missing an installer. See http://stackoverflow.com/questions/7922105/install-windows-service-created-in-visual-studio I came to this conclusion because of the install log file that contained the error, "No public installers with the RunInstallerAttribute.Yes attribute could be found in the c:\jenkins\jenkins-slave.exe assembly. Committing assembly 'c:\jenkins\jenkins-slave.exe'." – Steve Brownell May 10 '16 at 18:52

4 Answers4

61

I found another way to get the slave to install.

  1. Open a command window with "Run as Administrator".
  2. Change directory to the place where you saved the slave-agent.jnlp file.
  3. at the prompt run "slave-agent.jnlp"
  4. Now with the running slave click the menu item to "Install as Service".

The trick is to do it while running as an administrator. This installs the service running under localsystem.

Additionally, if you're like me and you need your jenkins routines to hit another machine, you'll need to change the service to run as a user with permission (network or otherwise) to do the task you want done.

Steve Brownell
  • 1,310
  • 1
  • 12
  • 18
  • Thank You this helped with my issue. – zalimgandhera May 20 '16 at 09:58
  • 1
    Thanks! this solution works for me too. Although according to the [Jenkins tutorial](https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service) I believe that .Net 3.5 needs to be enabled on the Windows 10 machine like so: 1. Windows key+s 2. Search and choose "Turn Windows Features on and off" 3. Tick the ".NET Framework 3.5" box 4. Press OK. you may need to reboot your machine to apply this change. Oh and @AhmedDaniel I think you can close or update [your Jira](https://issues.jenkins-ci.org/browse/JENKINS-34125) issue now ;-) – J00MZ Jun 09 '16 at 14:39
  • Oh I forgot about that. Thanks for reminding, i'll close it now. – zalimgandhera Jun 10 '16 at 05:23
  • 1
    Just to add to Steve Brownell's answer: A fresh "slave-agent.jnlp" file can be downloaded from Jenkins using the node's "/slave-agent.jnlp" endpoint (e.g. myjenkins:8080/computer/node1/slave-agent.jnlp) – Robert Jul 07 '17 at 15:04
10
  1. Open a command window with "Run as Administrator".
  2. Just in case, You may have trouble with the .jnlp in "Steve Brownell" instructions, then, run the first line of your error message, shown below. c:\JenkinsWorkDirectory\jenkins-slave.exe install
Anantha
  • 109
  • 1
  • 2
2

goto your downloaded jenkins-slave.exe Application file.

goto properties -> compatibility -.> check run as administrator.

Now try installing it as service again. It will work.

Ras
  • 543
  • 1
  • 9
  • 25
2

"C:\Program Files (x86)\Java\jre1.8.0_161\bin\javaws.exe" slave-agent.jnlp just run this from command prompt my issue got resolved from this as an administrator

Rahul Modi
  • 31
  • 1