Unable to start service in window 10 by using NSSM - powershell

I have create a small script file to test.
This my script.bat file.
sc create myService binpath= C:\Users\Admin\Desktop\test.bat start= auto
This is my test.bat file.
echo "Welcome to Wizard"
Problem Statement
I am unable to start the service from control panel Service section.
I get following error.
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
That is why I am using nssm.
NOW what happening is that when I run following command on powershell
.\nssm install myService, I dialogue box appears. I give it the path of my script file and click on install service.
After successfull installation of service. I go to control panel -> Service -> click on start against myService but it get paused and following dialog box appears
How can I fix this?
Is there anyother way to do it without doing manual steps and not using third party tool.
I am doing all this on window 10. Do I need any server to perform this task?
NOTE: I cannot use Always up or window scheduler in my case.

The NSSM behaviour is caused by the script terminating almost instantly. Try the following script:
echo Hello World
pause
This should allow the service to start, but you will not necessarily see a console window. Even if you tick 'allow service to interact with desktop', it will not be your desktop that it interacts with!
Windows implements 'session zero isolation' as a security feature, and this essentially prevents services interacting with end user desktops.
In terms of a solution, it's possible to write Windows 'service' applications fairly simply using Visual Studio. It's outside my area of expertise, but based on the Windows applications I'm familiar with, you would generally have a user-mode application running to provide desktop interaction. The user-mode application can interact with services hosted by the service application.

Probably this is resolved by now, but in case it helps anyone, what saved the day for me was checking again my input in the arguments field in nssm. I had an extra "-" which created the error. To edit my service, I went via nssm edit <servicename>

I would also add on the fix that worked for me. I added "" (quotes) in the argument path and that solved the issue for me.

Related

How to run a powershell script on startup in safe mode as an administrator

At the company I work for, we use Bit9 as part of our security stack. We are in the process of upgrade the version to 8.0 (and eventually 8.2) on all of our devices. Between the automatic upgrades and a different script I wrote, I was able to upgrade about 1000. But there are still about 700 left where the CLI password from Bit9 is not working, and the devices are not checking in to allow auto upgrade.
Bit9 has come back and suggested the following:
Boot the endpoint into Safe Mode w/ Networking
Run a script that executes the following Administrative commands from a CMD prompt (please note the proper spacing between start= disabled):
sc config parity start= disabled
sc config paritydriver start= disabled
Boot into Normal Mode
I've written a script that is supposed to do all of this, except I cannot for the life of me get the script to run once the device starts in safe mode. I've tried everything that I can think of:
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
Placing a batch file in the Startup folder
Scheduled task
Nothing I do is working.
And one other caveat, the user that is logging in (safe mode & normal mode) is not an administrator. It is a regular user. I am kicking off the initial script with BigFix, which does run as an administrator.
Thanks in advance.
I was finally able to get it to work. The service idea was the starting point, though instead of creating a "fake" service, I actually wrote a service in C# that calls the PS script. I was then able to edit the registry, where I made that service able to start in safe mode. That seemed to do the trick. Now the only issue is that I can't seem to disable safe mode programmatically, but I will ask that as a separate question.

zlogin usage in Runeck task

As part of rundeck task i'm trying to login to a global zone, use the command zoneadm list and trying to login to each of the local zone [to shut down various apps & to issue reboot] using the command /usr/sbin/zlogin and execute hostname command to ensure it did login to localzone
however this is not working
Is there a better way to do this? Please guide
Make sure that your job is dispatching to your remote node correctly, you can call the command on "Commands" (right panel) pointing to your node (referenced in the "Nodes" textbox) in that way you can discard possible path/user rights issue, take a look at this. Now, zlogin seems an interactive shell, and as you can see, you need to use it in the non-interactive mode.

How to check if a Blue Prism Server service is running?

I am trying to use the scheduler in Blue Prism and followed this guide to configure everything. However, my scheduled tasks are not running (nothing is started, there is no recent activity). One of the requirements to run a schedule is to have the blue prism server service running. How do I check this?
I have attached here some screenshots of my configured scheduler. The pending status on the timetable just disappears when I do "Run (schedule) now", and a checkmark never appears. The logs are also empty with no start or end time.
The answer is simple - you're doing everything correct, but it's impossible to run a scheduler on the evaluate licence. Once you'll have a production licence and application server, then it should work as expected
have you got Blue Prism Server installed and running. You need to connect to SQL database through Blue Prism Server.
You can find instructions how to set up a Blue Prism Server locally here:
https://www.youtube.com/watch?v=TXeNCJ60SMI
Finally you need to disable the interactive mode on your machine:
The interactive run mode may be disabled via System Manager in System, Settings, (uncheck “Start the process engine on this machine when users sign in”) in order to avoid it conflicting with the Resource PC mode, for example).
And run a separate instance of Blue Prism as resource pc from command line:
"C:\Program Files\Blue Prism Limited\Blue Prism Automate\Automate.exe" /resourcepc /public /dbconname ""

Use Wix Installer to install a service.

everyone, I'm using Wix to make an installer to run a service, below are my problems:
I use a custom action to call sc.exe to install and start the service, then I use custom action to call sc.exe [stop/delete] to remove the service when uninstall. This works fine except that a messagebox says
"The setup must update files or services that cannot be updated while the system is running, if you choose to continue, a reboot will be required to complete the setup"
But in fact after I click "OK", no reboot happened, and the service uninstalled successfully, how can I get rid of this message box?
Another problem is that, after click "OK" in the message box, another messagebox will pop up and tells me that "Another program has exclusive access to file [fileA], please click retry", and after I click retry, the uninstall finished successfully. [fileA] has been removed, but another file [fildB] was left behind.
but I do use a component :
<Component
<RemoveFile ..
<RemoveFile ...
</Component>
to remove these files. and I have
<Custom Action="StopService" Before="RemoveFiles">..
<Custom Action="RemoveService" After="StopService>..
In my wix .
Anyone has some suggestions?
It seems like service may not have actually shut down by the time Windows is trying to delete it or handles or process are still open to it may be for this reason its prompting for that massage box requiring a reboot to delete.
Windows can't uninstall a service if there are process/handles open to it.
In present scenerio after reboot i guess it will delete remaining files.
Try providing wait in your Custom Action for stop and remove service Provide asyncWait in return tag.
It might Solve your problem.
You are using SC.exe to control service via. custom action instead of this i recommend you to use WIX ServiceControl element.
Try to move the StopService and RemoveService custom actions before the costing standard actions, this is where Windows Installer analyzes to see what resources are in use and decides it if will prompt the user with the mentioned message box or not.

Jenkins windows slave service does not interact with desktop

I have followed this guide to install a jenkins slave on windows 8 as a service:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service#InstallingJenkinsasaWindowsservice-InstallSlaveasaWindowsservice%28require.NET2.0framework%29
I need to run a job that interact with the desktop (run an application that opens a browser etc.). So after I have installed the slave as a service (running jnlp downloaded from the master) I have changed the service "Log on" to "Allow to interact with display".
For some reason its only possible to enable this for the "Local System account" even though its recommended to run the service as a specified user, eg. jenkins.
But nothing happens when I execute the job, the browser is not opened. If I instead stop the service and just launch the slave through the jnlp file the job runs fine - the browser is opened.
Anybody had any luck interacting with the desktop when running a jenkins windows slave as a service?
Services run since Vista in Session 0 and the first user is now in Session 1. So you can't interact any longer. This is called Session 0 Isolation.
Microsoft explains this here and here. You have to use 2nd Program which uses IPC to communicate to the Service.
I had lots of issues running Jenkins in Windows using the service.
Instead I now disable the service and run it from CMD.
So open CMD.
cd C:\Program Files (x86)\Jenkins
java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar
jenkins.war --httpPort=9091
To resolve it, first create Windows auto-logon as I explain here:
https://serverfault.com/questions/269832/windows-server-2008-automatic-user-logon-on-power-on/606130#606130
Then create a startup batch for Jenkins agent (place it in Jenkins directory). This will launch agent console on desktop, and should allow Jenkins to interact with Windows GUI:
java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp
(slave.jar can be download from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)
EDIT :
If you're getting black screenshots (when using Selenium or Sikuli, for example), create a batch file that disconnects Remote Desktop, instead of closing the RDP session with the regular X button:
%windir%\system32\tscon.exe %SESSIONNAME% /dest:console
Consider running the Java slave server directly at startup and then using something to monitor and restart should the server go down (e.g., Kiwi Restarter).
Please check the services (# TestNode) make sure the "Interactive Services Detection" service is STARTED, by default the startup type is set to Manual, you may like to set it to automatic as well.
After service started, when you run your test in the Test Node, you will see something like the below:
Click on it and choose view the message
You will see the activities happen there. Hope this helps :D
Note: If login with other account and cannot view the Interative Services Detection prompt, restart the service again.
My Jenkins Service runs as user "jenkins" and all I did was to create Desktop folders in: C:\Windows\system32\config\systemprofile\desktop and if 64 bit Windows also in C:\Windows\SysWOW64\config\systemprofile\desktop - then it runs perfectly.
Make sure that Desktop folders are created as such:
%WINDOWS%/System32/config/systemprofile/Desktop
%WINDOWS%/SystemWOW64/config/systemprofile/Desktop
Presence of those can sometimes be mandatory while running some Java software as a Service.