Cannot get .bat file to run after installation with Qt installer - postgresql

I'm needing to run a bat file when the installer is finished that plugs in a postgres windows service so my database has an active server (I'm using a static postgres). The bat file runs the pg_ctl register command.
According to the Qt Installer Documentation installationFinished is what you use to issue methods that will run once the installer is complete via the controller or package install scripts. I'm not sure if i'm using it correctly because after running the installer the bat file doesnt run. How is this function used properly?
I have tried in the controller script:
Controller.prototype.installationFinished = function(){
installer.executeDetatched("C:\\Program Files (x86)\\PostgreSQL\\9.6\\pgserv.bat", new Array(), "#homeDir#")
}
also tried in the component install script:
Component.prototype.installationFinished = function(){
component.addElevatedOperation("Execute", "cmd", "/C", "C:\\Program Files (x86)\\PostgreSQL\\9.6\\pgserv.bat");
}
This bat file is to run post install because the command on the bat file requires the postgres\bin folder that is added to the PATH variable after install.
Thanks a lot for any help folks! :)

Try this one:
Component.prototype.installationFinished = function()
{
QDesktopServices.openUrl("file:///" + installer.value("TargetDir") +
"/file.bat");
}

Related

PowerShell executing .bat files with in the same session

I am installing a software in silent mode using PowerShell. Installation was done successfully but when I am trying to execute few batch files I am getting some exceptions.
Could not find the files for the given pattern. The system can not find the specified path.
My command inside my PowerShell:
$inst_path = \\My installed drive (c:\program files\mysoftware\)
& $inst_path\start-service.bat install
But when I closed the PowerShell ISE and executing the same command it is working without any exceptions, so can someone help me overcome this?
You've got a double slash in the path to the bat file, both the $inst_path variable and the path you construct.
You're trying to call c:\program files\mysoftware\\start-service.bat - which is going to fail.
Try this instead:
$inst_path = "c:\program files\mysoftware"
& "$inst_path\start-service.bat" install

Install4j doesn't write into the java preferences store

I have two installer i1.sh & i2.sh and both have respectively i1.varfile & i2.varfile where they customize the installation directory.
First, we launch the i1.sh as this:
[localhost]$ sudo ./i1.sh -q
The i2.sh is launched by the i1.sh via the action Run executable or batch file.
The problem is that in the file sudo vi /root/.java/.userPrefs/com/install4j/installations/prefs.xml an entry exists only for the i1 but never for the i2.
[Edit]
After watching this file with the command:
watch "sudo cat /root/.java/.userPrefs/com/install4j/installations/prefs.xml"
We noticed that the entries for i2 are added and directly overwritten by those of the i1.
Any ideas plz?
Thanks
The solution is to run a script after the launching of the second installer to synchronize the prefs.xml
Run script Action:
java.util.prefs.Preferences.userRoot().sync();
java.util.prefs.Preferences.systemRoot().sync();
return true;
Special thanks to the install4j support team

Install Windows Store App via Visual Studio Installer (C#) and PowerShell

I want to install a Windows Store App with an easy to use msi Installer.
I'm using Visual Studio Installer to create the msi package.
The Windows Store App can, without the store, only be installed via PowerShell.
Working:
Installer completes successfull.
Needed changes to "AllowAllTrustedApps" and the installation of the certificate are working.
Not working:
Installing the appx package via C# Code in PowerShell doesn't do anything
Installing the certificate via PowerShell works:
using (RunspaceInvoke invoker = new RunspaceInvoke())
{
invoker.Invoke("certutil.exe -addstore -f \"TrustedPeople\" \"C:\\Program Files\\App_1.0.0.0_x64.cer\"");
}
Installing the appx doesn't work:
using (RunspaceInvoke invoker = new RunspaceInvoke())
{
invoker.Invoke("Add-AppxPackage -Path \"C:\\Program Files\\App_1.0.0.0_x64.appx\"}");
}
Also tried this with .ps1 Files.
My thought was that the code can't handle the progress bar that appears when the app is installed in PowerShell and kills it. So I wanted to start a new PowerShell window:
using (RunspaceInvoke invoker = new RunspaceInvoke())
{
invoker.Invoke("cmd \c start powershell -Command {Add-AppxPackage -Path \"C:\\Program Files\\App_1.0.0.0_x64.appx\"}");
}
But that generates an exception I can't really read, because it closes the window very fast. The exception contains the following:
Adding the package was denied, because the process uses the local
systemaccount.
But it's running with administrator rights! Installing everything with direct use of PowerShell works. So every command should be correct.
Any ideas whats wrong? Don't know what to google for anymore...
Thanks in advance
Regards,
Sebastian Neurohr

Cannot Execute FTP commands through ClearCase trigger

I have a ClearCase trigger that runs a .bat file and it works perfectly. What I want to do now is have it run some FTP commands, in my case using WinSCP. I have a command ready in another .bat file which, when run manually, works. When I invoke this .bat file from the .bat launched by the ClearCase trigger, however, it does not work. I have no idea why!
The command in the triggered .bat file is call ftp.bat.
Any ideas? Could it be permissions?
Thanks,
Andrew
As the OP Andrew reports, WinSCP isn't practical when called from another bat.
This would not run:
"C:\Program Files\WinSCP\winscp.com" /script=sftp_script.txt
However, this will, based on psftp (from PuTTY):
echo y | psftp %FTPUSER%#%FTPSERVER% -pw %FTPPASS% -b psftp_script.txt

Jenkins launches a Perl script that has ANT in it, but ANT is unable to read a .properties file

Previously I had Jenkins launching a perl build script that at some point during the script would open up a .bat file that launched our ANT jobs. I'm trying to consolidate and get rid of the .bat files and launch ANT straight from the perl script. I have been able to successfully do this, but the problem is the .properties file that the ANT script looked at for it's variables is no longer being imported correctly as it was when the .bat file launched the ANT script.
Currently I'm just called an "Exec("ant -buildfile C:\project\buildfile.xml") and that fires off the ant, but it comes back with an error, "Cannot find ${script.dir}/barbuildfile.xml". The "script.dir" is being defined in a .properties file that is located in the same directory as the build files. This works perfectly when it's launched by the .bat file, but it fails whenever it's called through Perl. Any reason why? Or better yet, how to fix it?
I have also tried forcing it to load the properties file by launching. "Exec("ant -buildfile C:\project\buildfile.xml -Dpropertyfile=C:\project\build.properties")" and receive the same error.
Edit:
This is the.bat file
set project.name=%1
set environment=%2
set version.tag=%3
set build.list=%4
set JAVA_HOME=C:\ProgramFiles\IBM\jdk
set ANT_HOME=C:\ProgramFiles\IBM\IMShared\plugins\org.apache.ant_1.7.1.v20100518-1145
set PATH=C:\Program Files (x86)\IBM\IMShared\plugins\org.apache.ant_1.7.1.v20100518-1145\bin
CALL ant -buildfile C:\scripts\build_service.xml
Perl Script:
system("set project.name=$project");
system("set environment=$environment");
system("set version.tag=$version");
system("set build.list=$service");
system("set JAVA_HOME=C:\ProgramFiles\IBM\jdk");
system("set ANT_HOME=C:\ProgramFiles\IBM\IMShared\plugins\org.apache.ant_1.7.1.v20100518-1145");
system("set PATH=C:\Program Files (x86)\IBM\IMShared\plugins\org.apache.ant_1.7.1.v20100518-1145\bin");
exec("CALL ant -buildfile C:\\scripts\\build_service.xml
First, please consider calling ANT directly from Jenkins
via the dedicated ANT Plugin, as mentioned by Demnogonis.
Second, the way it is currently written, each system(...) command runs in its own CMD window,
without any knowledge of the other system commands that ran before it
(those previous commands already went out-of-scope), for example -
Changes made in 'my_setup.bat' are NOT available to 'ANT':
exec("my_setup.bat");
# at this point, 'my_setup.bat' is forgotten
exec("ANT ...");
or
system("my_setup.bat");
# at this point, 'my_setup.bat' is forgotten
exec("ANT ...");
Setup in 'run_my_ant.bat' are known to ANT, assuming ANT is called from within the BAT-file,after the changes were made:
exec("run_my_ant.bat");
To overcome this, use the %ENV hash to set variable in your environment,
in a way that will make them available for other commands in your script:
$ENV{'project.name'} = $project;
$ENV{'environment'} = $environment;
$ENV{'version.tag'} = $version;
$ENV{'build.list'} = $service;
$ENV{'JAVA_HOME'} = "C:\\ProgramFiles\\IBM\\jdk";
$ENV{'ANT_HOME'} = "C:\\ProgramFiles\\IBM\\IMShared\\plugins\\org.apache.ant_1.7.1.v20100518-1145";
$ENV{'PATH'} = "C:\\Program Files (x86)\\IBM\\IMShared\\plugins\\org.apache.ant_1.7.1.v20100518-1145\\bin";
exec("CALL ant -buildfile C:\\scripts\\build_service.xml ...");
See also here:
How do I set an environment-variable in Perl
Can we set a variable used in perl script as environment variable
Good Luck!