jjones
Posts: 68
Joined: Wed Jun 29, 2011 3:30 pm

Running .exe as Custom Action

Wed Apr 11, 2012 4:13 pm

I am trying to run an executable via a custom action that relies on some temporary files to execute. For some reason, I have been unable to get the SQL Scripts to run using Advanced Installers "SQL Scripts" built in features (I'm going to post a separate thread about this if I can't solve the problem). So, I have included all the files necessary to run sqlcmd.exe and drop the tables that way. The files are an .exe, .dll, and five (5) scripts. Below is the Command Line:

"[#SQLCMD.EXE]" -U xx -P xxxxxxxxx -S [ComputerName]\SQLEXPRESS -i "[#Script1.CreateDatabaseWithFilestream.sql]" -i "[#Script2.Logins.sql]" -i "[#Script3.GX2DatabaseObjects.sql]" -i "[#Script4.DataStaticScripts.sql]" -i "[#Script5.AirCylinder.sql]"

I've verified that the files are in the Temp directory during installation and the action is done after AddResources but before FinishExecution. However, when the action tries to run, it says that it could not complete the action. I've checked the log file and the path for all the files looks right but it just doesn't run. Any ideas?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Running .exe as Custom Action

Thu Apr 12, 2012 11:26 am

Hi,
I am trying to run an executable via a custom action that relies on some temporary files to execute. For some reason, I have been unable to get the SQL Scripts to run using Advanced Installers "SQL Scripts" built in features (I'm going to post a separate thread about this if I can't solve the problem).

Can you give us more details about why you are unable to run your sql scripts using our SQL Scripts feature? Please keep in mind that we recommend to run sql scripts using a custom action only when an uncommon scenario is encountered.
So, I have included all the files necessary to run sqlcmd.exe and drop the tables that way. The files are an .exe, .dll, and five (5) scripts. Below is the Command Line:

"[#SQLCMD.EXE]" -U xx -P xxxxxxxxx -S [ComputerName]\SQLEXPRESS -i "[#Script1.CreateDatabaseWithFilestream.sql]" -i "[#Script2.Logins.sql]" -i "[#Script3.GX2DatabaseObjects.sql]" -i "[#Script4.DataStaticScripts.sql]" -i "[#Script5.AirCylinder.sql]"

Your command line seems to be correctly edited. You could encounter problems when your custom action is executed because on some operating systems elevation rights may be required. So, you should enable the "Deferred with no impersonation" option for your custom action from "Executing Option Group", build your project and try again to run your package.

Plese keep in mind that you can add temporary files in your project only using the [Add Temporary Files] toolbar button. If you use the [ Add Files... ] toolbar button to add files in your "Temporary" project folder, then the added files will be regular.

Let us know if this helps, otherwise please give us more details about your scenario.

Regards,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

jjones
Posts: 68
Joined: Wed Jun 29, 2011 3:30 pm

Re: Running .exe as Custom Action

Thu Apr 12, 2012 2:20 pm

Daniel,

Thank you for the prompt reply! I think the reason my scripts are not running is because of the statement separators. The scripts are using both GO and ";". I plan on going back and editing these so they will work but if I can at least get this custom action to work that will enable others to do a full install of the system without my help.

I will go back and make sure I added the temporary files correctly as well as change the level of permissions.

jjones
Posts: 68
Joined: Wed Jun 29, 2011 3:30 pm

Re: Running .exe as Custom Action

Fri Apr 20, 2012 2:11 pm

I have gone through several iterations of trying to get the scripts installed outside of the built-in functionality in Advanced installer (I have a separate post about that).

1. I have tried the above method (calling sqlcmd.exe directly) with all the files added as temporary files and regular files. I have verified that they show up in the temporary directory but when the custom action runs, it says there was a file missing or there was a problem.

2. I have tried just running a batch script that has the sqlcmd.exe line built into it. The .bat file (and all the other needed files) were again added as both a temp and regular files but again, when the custom action was run it said there was a problem.

Both of the above custom actions were set to "Deferred with no impersonation" and were run between Add Resources and Finalize installation. Both of the above methods have been verified independently outside of Advanced Installer. The exact same .bat file is used by a standalone database installation that installs SQL Express silently via a .ini file and then sets up the tables.

Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact:  Website

Re: Running .exe as Custom Action

Mon Apr 23, 2012 1:09 pm

Have you tried creating a verbose log? That should contain more details about the failed custom action.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

wonderman
Posts: 1
Joined: Wed Sep 25, 2013 3:57 pm

Re: Running .exe as Custom Action

Wed Sep 25, 2013 4:04 pm

I know this thread is pretty old now but I am having an issue that may shed some light. OP says "The exact same .bat file is used by a standalone database installation that installs SQL Express silently via a .ini file and then sets up the tables" and it appears that if a .bat files includes a SQL install, then running sqlcmd from within that same .bat file will cause sqlcmd to fail. So, you may just try breaking out your .bat file into two; the first containing the SQL install, the second containing the sqlcmd commands.

Bogdan - is this something you have ever come across?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Running .exe as Custom Action

Thu Sep 26, 2013 2:55 pm

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

We never came across this scenario. However, this may happen if you are not specifying a full path for the SQLCMD.EXE in the related BAT file. Can you please try to specify a full path for the SQLCMD.EXE (e.g. C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.exe) and see if the behavior still persist?

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”