For my installation, I am trying to install both my database server (which is postgresql) and my application server as services. I know it is possible to install postgres using pg_ctl from console by starting it as admin. But as far I know it is not possible for java to start cmd.exe in administrative mode. So I was hoping to be able to achieve it by Install4j. I saw the sample "hello" project. But there it creates a launcher. But in my case for postgresql I need to run the pg_ctl along with some arguments. And for application server I have my own batch file as the executor. For PGSQL I have tried giving windows arguments i.e. -N service_name -D data_folder. But for both cases it fails to start the service. I also tried manually from the Services menu in Windows it fails to start. I have the account setting as "local system".
I have also tried running pg_ctl using "run executable or batch file" action but still I could not find the service in the windows services list, not to mention the same arguments work fine from command prompt. I have added a figure of the action properties I used in the project.
If your installer has executed a "Request privileges" action and you execute pg_ctl.exe with a "Run executable or batch file" action, it will be executed with admin privileges, because the the default value of the "Action elevation type" property of that action is "Elevate to maximum available privileges".
Related
I ran into a very strange issue. I need to configure proxy in my Jenkins to be able to access SVN repository in one of the jobs. I have done so in 2 ways:
Started Jenkins from command line with the required arguments
Started Jenkins as Windows service while the arguments are defined in the jenkins.xml file.
Starting from command line:
C:\>java -DJENKINS_HOME="C:\.jenkins" -Dhudson.model.DirectoryBrowserSupport.CSP
="`script-src 'unsafe-inline';`" -Dhttp.proxyHost=localhost -Dhttp.proxyPort=312
8 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar %JENKINS_HOME%\jenkins
.war
Starting as service (below is the jenkins.xml contents):
<executable>java</executable>
<arguments>-DJENKINS_HOME="C:\.jenkins" -Dhudson.model.DirectoryBrowserSupport.CSP="`script-src 'unsafe-inline';`" -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar "%JENKINS_HOME%\jenkins.war"</arguments>
So that's exactly the same. The issue however is that when I am using command line to start Jenkins, proxying works fine. But when I start Jenkins as service, the repo (through the proxy) cannot be accessed and I get this error message:
Please note that if I look at the System Properties in System Information section, the proxy parameters appear the same in both cases so the configuration is being applied properly:
Apparently there is a difference in how Jenkins starts up depending on how it was started (command line or windows service). What reinforces this assumption is that I see that some log files are only being written when I start Jenkins as a service but not when I start it from command line. I am talking about these log files:
jenkins.wrapper.log
jenkins.out.log
What do I need to do differently to get the same result from Jenkins as service as I do when I start it from command line? What configuration am I missing?
Jenkins as a Windows service doesn't run under your current user but under the LocalSystem Account by default.
See MSDN: Using the LocalSystem Account as a Service Logon Account and SO: The difference between the 'Local System' account and the 'Network Service' account? for the implications.
I have some question when using jenkins.
the scenario:
I have installed a tomcat on machine A,and config all necessary environment including JDK, and they work well.
I wrote a shell script named restart.sh to kill the tomcat process,and restart.
I execute the script and it works well.When I check the tomcat process using ps -ef,and it shows the exact JDK path as I already config.The JDK path is /usr/local/java/JDK7
When I execute the restart.sh script via jenkins,problem comes. I can see the tomcat process using the wrong JDK path,/usr/bin/java,not the path as i config. I use SSH Publishers plugin to run the remote script.see as the image below:
enter image description here
I don't know how this problem happen,please help,Thanks all
This might be the problem of path variables, just to cross verify , find JAVA_HOME on your server 1. By logging onto server manually 2. From Exec command of your ssh section of your jenkins job , most probably you will find the answer.
i'm assuming you're jenkins is configured to use jdk which is defined at its root level.
if this didn't solve , we need to look into this problem from another angle.
I have a java application, which has to run as windows service.
I am able to install the service using the following command.
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass %STARTER% --StopClass %STOPPER% %START_PARAMS% %STOP_PARAMS%
The service is installed successfully but when i try to run it it shows Failed to create java. path also it is not showing in the jkartha log file.
I have JAVA_HOME environment variable pointing to jdk1.5.
and even i copied msvcr71.dll to windows\system32 folder and restarted the PC.
I am running this on windows 2008 server.
I didn't install apache tomcat server. prunsrv.exe and procmgr.exe i just copied.
Please suggest me how i need to overcome this problem.
whether to run application as windows service, prunsrv.exe, prunmgr.exe are enough is it? I am able to successfully install but not able to start why???
You probably need to set your service to run as the user that installed Java, otherwise it won't find its environment variables.
If you must run in the default Local System account, then you can run a batch file that sets up the environment and then launches java.exe.
Running .bat file in Windows 2008 as admin.
I have Java Application installed in Windows 2008 as user (Name of user is Test. Group of user is Admin). This application is using JSW and generating .bat file for starting application in Windows platform. This .bat file are created with help of maven plugins.
Now the problem is if I click on .bat file as normal windows user with default security settings then it does not start my application. If I start .bat file as "Run as Admin" then application starts. If I change security setting of 'Test' user and make is liberal then I can start application without running 'Run as Admin'.
I want to automate this step. I don't want user to do 'Run as Admin' or change their security settings. So I came up with solution that run some vb script after installing application by installer so that file make some security settings of that .bat file so 'Test' user can start .bat file in one step. Is this possible or any better solution ?
By the way I am using Install Anywhere for installer.
After trying for some time I figured out that I can also change setting (Advance Properties) of shortcut file which point to .bat file. This Shortcut have advance properties where there is option "Run as Administrator". If that option is checked then my issues is solved. So I was wondering is it possible to check that option in from vb script? If yes then any hints? and if not then what are alternation to do that?
I found http://nsis.sourceforge.net/ShellLink_plug-in but I do not how to do that in vb script.
I don't think it's possible to do that in a batch file without prompting for password. You could make a small c++ launcher to request privileges and then run your java application.
what version of JSW are you using?
Starting with version 3.5.7 of the JSW, it will automatically request an elevation to Administrator privileges when you start/stop a java application as Windows Service.
This is from the JSW release notes for 3.5.7:
Implemented a way to install, remove, start, stop, etc., the Wrapper
as a Windows service from a non-elevated (UAC) console. The Wrapper is
elevated transparently using a child process. This is needed starting
with Windows Vista and 2008 for smooth interaction with the Windows
Service Manager.
Cheers,
I would like to run the GWT shell (the nice little Google pop-up browser window) when "testing" and upon clicking the actual "Compile/Browse" on the tool, compile the program into a different directory and use the -noserver mode to test it on my IIS server.
Problem:
I have not edited the normal shell script, so it fires off just fine. The edits I make are viewed upon refreshing. The compile/browse however, shoots me off to mini-Tomcat server instead of my directory. The compile DOES appear to be running (as I can browse to that directory directly and it is receiving updates), but the compile/browse does not shunt me there.
Here is the compile script I've got right now:
#java -Xmx256M -noserver -port 80 -cp "%~dp0\src;%~dp0\bin;C:/dev/gwt-windows-1.5.3/gwt-user.jar;C:/dev/gwt-windows-1.5.3/gwt-dev-windows.jar" com.google.gwt.dev.GWTCompiler -out c:/dev/Practice /Practice/Practice.html
Clearly the area I would LIKE to go is "http://localhost/Practice/Practice.html" (the IIS server) but it is jumping to "http://localhost:8888/practice.Practice/Practice.html" (the Tomcat server).
Ideas?
(P.S. Running Eclipse for editor, the Run/Debug config arguments are:
practice.Practice/Practice.html
and that's it)
You can make an Eclipse run profile for the GWTCompiler class. One of the arguments you pass in is the path to compile to, so you could run the compile from Eclipse and it would write the files directly to the IIS's folder if you specified it. Once the compile is done, you can use the already open Hosted Mode instance and just type in the http://localhost/Practice/Practice.html path, and it'll work.
The Hosted Mode browser can be pointed at any server even without running it with -noserver, and if you get security warnings about leaving the domain, you can add a -whiteList argument to the Hosted Mode run profile. The security warnings will give you an example whiteList argument.
Try running GWTCompiler and GWTShell with no arguments for the possibilities. I'd be more detailed, but I don't have a dev environment with me right now.