Can not install a poweroff service - service

Actually I try to install a service called poweroff. This service normally will be installed from a software also called poweroff.
You find it here under old projects:
http://users.telenet.be/jbosman/applications.html
Until now on each pc i want to install the service I use an .cmd file with the content
poweroff.exe shutdown -create_service -msg "This computer will be shut
down!" -warn -warntime 10 -wait 10 -force -allow_remote -remote_port
3210 -remote_pswd password
it creates the service so I can see it inside the services.msc program.
But now on one pc this command do nothing and when I try to create the service inside the poweroff program there comes an message "Access denied".
Because I logged on as administrator I think not that it is an right problem.
Do anyone have an idea why the service will not created?

It seems that the problem was the access to the folder C:\Windows\System32.
After adding the poweroff.exe file to this folder the service could be created without problems.
Thanks to Jorgen Bosman for helping me to find this solution.

Related

Using SC.exe post installUtil

I am trying to understand what is the correct way to uninstall a service.
According to Microsoft here, there are two ways to uninstall a service:
// Using installutil
installutil -u <yourproject>.exe
// Or using Powershell
Remove-Service -Name "YourServiceName"
In both examples, Microsoft states the following thing:
After the executable for a service is deleted, the service might still be present in the registry. If that's the case, use the command sc delete to remove the entry for the service from the registry.
sc.exe delete "YourServiceName"
Assuming most people will run a script to uninstall a given service using one of the above methods, how can we determine (from a batch or powershell script) if the uninstall worked properly or not (so that I can only conditionally run sc.exe)? In other words, how can we check that a service is still in the registry as per the Microsoft quote.
Also, I have been so far using sc.exe without prior uninstalling and it seems to have the desired effect.
ie. My service gets removed from the list of running Windows services and I am able to start with a fresh new installation of my service.
Is this a bad approach? If so, why is it a bad approach?

Unable to copy files from remote directory from IIS service using powershell script

I have a few files that need to be copied from a Server A to Server B. There is an IIS service running on Server B which calls a local powershell script to do the needful.
When the powershell script is executed from the command line, it works as expected and also works when executed from within IISExpress. But when called from the service hosted on IIS, there is no error reported, but no files get copied either.
The powershell script basically calls Copy-Item -Path \\Server A\<some path> -Destination c:\<some path>
Thank You!
IIS by default runs as a local service account that doesn't have network permission. You probably couldn't see an error message because the Powershell script wasn't echoing it's output to the HTTP response.
To fix this you can create a new Application Pool in IIS and set the identity by entering network credentials in the AppPool's Advanced Settings -> Identity.
Then make your Service run in that AppPool by right-clicking on the Virtual Directory and selecting "Add Application". A dialog box will appear where you can select the new AppPool.
Notes:
The credentials you enter in the AppPool are not updated when the network password changes, so you should use a domain account with a password that doesn't expire.
You should not use your own account because it could get locked out if your password changes and your service is invoked.
The password is readable by any administrator on the IIS server.

Unable to start service in window 10 by using NSSM

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.

Issue when uninstalling a service?

I am trying to uninstall a recently installed service, I am running this in command line:
c:\Windows\Microsoft.NET\Framework\v4.0.30319>installutil.exe /u "C:\inetpub\www
root\xxx\xxx\xxx.exe"
But I am getting this:
The uninstall has completed.
An exception occurred while uninstalling. This exception will be ignored and the
uninstall will continue. However, the application might not be fully uninstalle
d after the uninstall is complete.
And this:
Removing EventLog source xxx.
An exception occurred during the uninstallation of the System.Diagnostics.EventL
ogInstaller installer.
System.Security.SecurityException: Requested registry access is not allowed.
An exception occurred while uninstalling. This exception will be ignored and the
uninstall will continue. However, the application might not be fully uninstalle
d after the uninstall is complete.
I have no idea where to begin and I really need to uninstall these so any help is appreciated
I was facing exact same issue.
The issue is resolved by opening the Command Prompt as Administrator.
My guess is that you are probably trying to remove a service using a user account which does not have sufficient rights. Specifically, the issue in this case is the removal of some EventLog registry keys during Uninstall.
This may also occur when you are logged in as a user with Administrator privileges yet did not run the Command Prompt in 'Administrator Mode'.
One way to fix this is to make sure that you are running the Command Prompt in Administrator mode. (Right-click > Run as Administrator)
I have also encountered some cases where this method still fails to solve the SecurityException problem due to some registry keys not having 'Full Control' permissions for Administrator accounts.
The following keys should have 'Full Control' set for Administrators in order for the service to be able to write to the EventLog:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application
This may be done by:
Invoking the Windows Registry Editor
Run [Win + R]
Type 'regedit'
OK
Navigate a path listed about
Right click on the desired path
Make sure that both Read and Full Control permission checkboxes are ticked for Administrators
Click Apply and OK
Repeat the same process for the other path

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.