How to start Appium on Windows automatically

I have a windows machine that I’m using for testing (Xamarin Droid and WPF, i’ll ). I have Selenium running as a server when the machine restarts but I can’t figure out how to get appium to start when the server restarts. Everything works fine if I start appium (say via the desktop app) manually.

I’m probably missing an important idea and doing things the wrong way.

Our tests are in C# and we are using Teamcity and Octopus for building and deployment.

1 Like

@adam.vandenhoven

  1. install Appium as NPM to start in command line
    1.1) install NPM for windows -> https://blog.teamtreehouse.com/install-node-js-npm-windows
    1.2) now install appium with npm as “npm install -g appim” in command line

  2. register APPIUM as SERVICE! using simple and nice tool -> https://nssm.cc/usage

now every restart of PC Appium will start even without login

1 Like

@Aleksei

Ok. So i installed NSSM and I added Appium as a service with C:\Users\user\AppData\Roaming\npm\appium.cmd and --log C:\Testing\log\appium.log --log-teimstamp --log-level error:debug --log-no-colors for the args. I have it logging in with the local system account and checked the “allow to interact with desktop” and have tried both normal and high priority and have tried with checked and unchecked console.

In every case, the service says its running but http://localhost:4723/wd/hub/status gives no response (and there is no appium.log file).

Any thoughts? Should I call node with the main.js file directly?

@adam.vandenhoven what happen when you start in command prompt:

C:\Users\user\AppData\Roaming\npm\appium.cmd and --log C:\Testing\log\appium.log --log-teimstamp --log-level error:debug --log-no-colors

does appium starting?

I have following errors:

  1. Unrecognized arguments: andlog-teimstamp.
  2. also pls make sure that path to log file exists

Ok yeah. it was the timestamp. stupid fingers :wink:

Thanks for your help.

@Aleksei

I’m spinning in more circles.

Appium is working and starting up when I restart but its not starting my WPF app when I run a test.

I’ve updated appium to 1.9.1 and WinAppDriver to 1.1, but it cannot start the app. The logs includes: {"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: C:\\Testing\\SystemUnderTest\\Latest\\WPF\\TestAutomation\\example.exe, and processId: 8900"}}

I also have the latest desktop app and when I run that my WPF app will start. Those logs use the same escaped path for the app so that’s not it. I’m thinking its a problem with the fact that its running from a servce?

Never worked with windows app and Appium. Sorry can not help.

Adam. What service context are you using to start the service?
It’s surely much easier to get your existing remoting framework (Jenkins agent or whatever) so spawn the service in the correct “interactive login session”, this worked on windows 7 and 8. Windows10 has changed service accounts and pretty much removed the old ways of getting interactive logins for services. So yes, it’s authentication related what you are seeing there.

I just wish we had more people regularly checking and trying to help out. Basically Windows removed the ability for services to interact without making code changes to the service that keep the service in a “sandbox”, so you are now stuck with autoadminlogon and autorun. I’ve detected issues with autorun in the past hence the suggestion that you run an “RPC agent” of your own in the autorun. and then use that to start the appium “server”.