PowerShell hangs - no response to keyboard actions - powershell

PowerShell hangs - no response to keyboard actions.
Do CD - ok
Do httpd.exe - Apache service starts OK,
but then Powershell just hangs.
Can only close window, but then Apache service stops.
Same on all versions of PowerShell

From the documentation:
Running Apache as a Console Application
Running Apache as a service is usually the recommended way to use it,
but it is sometimes easier to work from the command line, especially
during initial configuration and testing.
To run Apache from the command line as a console application, use the
following command:
httpd.exe
Apache will execute, and will remain running until it is stopped by pressing Control-C.
Run the program asynchronously as follows:
Start-Process -Filepath .\httpd.exe
Another option: Running Apache as a Serviceā€¦

Related

Install4j: Silent updater exits on start

I am running my installer in silent mode (-q option).
After starting, the installer quits. The error.log shows the entry:
"The application is running. Please close instances and run this installer again".
However, there is no other instance of the installer running.
Note - The installer is launched in the Windows local system account.
I encountered the exact same issue with an updater installer being run in unattended (silent) mode and launched from a Windows service. I discovered that there were two reasons for the updater failing to complete:
The unattended mode installer was being invoked with arguments -q -wait 20 (these are the defaults when generating an updater application using the install4j UI). The -wait argument causes the installer to wait for running applications to close before progressing to the stage where the Welcome screen would normally be shown in an interactive install. It does not attempt to close them itself. If the applications don't disappear within 20 seconds, the installer exits at this early stage with the error.log message "The application is running. Please close instances and run this installer again". (In interactive mode the user would be shown a screen at this stage asking them to close the running applications.)
(Note: -wait only seems to check for the presence of application processes (user launched apps, UIs etc). Installed services that are running are not considered a blocker, probably because they are automatically stopped as part of the Install files action.)
I had already added actions later in my installer to close down the application processes before installing the update, but the -wait argument was not allowing it to progress that far. I removed the argument from the "Set installer arguments" action in the updater app and this allowed the installer to progress beyond the welcome phase.
The 'Check for running processes' action, using a Close strategy of 'Soft close immediately', failed to close any user-launched applications running (UI applications in my case) when the installer was launched from the Windows service. This in turn caused the unattended update to fail due to locking issues overwriting the installed files.
However using the Close strategy of 'Terminate immediately' did allow the service account to successfully kill the running applications and allowed the installation to complete.
I ended up using a sequence of "Stop a service", "Check for running processes (soft close)" (which works when the installer is run in interactive mode by a user), then "Check for running processes (Terminate immediately)" at the start of the Installation section to cover all bases.

Jenkins start JBOSS inside of a job and go on

I have a Jenkins job where I want to
- build my application
- start the jboss via batch
- sleep some time to wait for the jboss
- do some junit tests
- stop the jboss
The problem I have is that the job does not proceed after the jboss start. It shows the complete jboss log and just keeps refreshing this log.
So the sleep and junit tests are never executed.
batchcall im using:
cmd.exe /C F:\jboss-5.1.0.GA-jdk6\bin\run.bat -c Servername -Djboss.service.binding.set=ports-05 -Djboss.bind.address=0.0.0.0
I can't use the jenkins jboss management plugin because i have to set java_opts for this specific job.
Any idea how to start the Jboss without showing the log in the jenkins console?
EDIT :
Thanks for your answer, but call/start didn't work for me either.
My working solution:
(not nice but it works, just thought i should share it)
I created a 2nd Jenkins job which starts the JBoss with the batch call from above.
Then changed this job to be triggered remotely. "Trigger builds remotely"
Now i changed my 1st job to trigger the 2nd in a build step "Execute batch command"
wget --spider build_trigger_url
So my Job is doing this now:
build my application
trigger the jboss jenkins job via wget
this 2nd job is now also running on jenkins, until it is manually shut down
sleep some time, until the jboss is started
execute junit tests
stop the jboss
via jboss management plugin, this kills the 2nd job
You should change it to cmd.exe /C call F:\jboss-5.1.0.GA-jdk6\bin\run.bat <whatever params>
When you trigger a .bat it passes control to it and runs it until the .bat terminates. Instead, you need to spawn off another process to run the .bat. This is done with call command.

Powershell how to run a program and waiting in a remote session

I have a command line program that listen to a tcp port until user type Q to exist. It works fine in local powershell window. But when I try to run it on another machine using powershell remote session, it just starts and quit. Is there a way to keep it running?
The remote script runs in a PowerShell that never becomes visible so AFAICT it doesn't even got a console handle by which to handle reading keyboard input.
You can take a look at the SysInternals utility - psexec. From my testing, that utility works for what you are trying to do.
Ensure you have Powershell 3 or higher since it adds support for detached sessions/background jobs.
Use a Remote Disconnected Session, described on Technet

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.

How can I start XServer in Linux through apache user triggered by Perl script running in background?

I am trying to launch MS Office through WINE using a Perl script hosted by apache
and and triggered by other application. I am getting the following error message in
log files "Application trying to create a window but no driver could not be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly".
If I run the script directly on shell prompt using root user then WINE starts
XServer properly and execute MS MSoffice in addition to that if I set xhost +local:apache on shell prompt then also it works fine.
How can I start the XServer from apache user?
It is an exceedingly bad idea to start a X server per httpd worker. If you insist on doing this though, use Xvfb.
My recommendation would be to have a separate daemon handle the document conversion/creation, and use a message queue to pass it jobs.