installscript


Execute command line statement in installshield / installscript


How do I execute the following command in installscript during installation?
netsh.exe advfirewall firewall show rule name="PowerSI (Release ASI 16.64)" || NETSH.EXE advfirewall firewall add rule name="PowerSI (Release ASI 16.64)" dir=in action=allow program="d:\Cadence\HIM_asi1664\ASI\Update4\SpeedXP\SpeedXP Suite x64\PowerSI.exe" enable=yes profile=any description="d:\Cadence\HIM_asi1664\ASI\Update4\SpeedXP\SpeedXP Suite x64\PowerSI.exe"
Note that the above command contains the executable name i.e. netsh.exe twice and this is where the problem is. I tried LaunchAppAndWait first by using the whole command as the name of executable and passing an empty string as argument. Next I tried was passing the first netsh.exe as program name and the remaining text as argument. Both the approaches did not work.
Custom Action Wizard --> Launch an Exectuable --> Stored in the Directory table --> SystemFolder (as source)
Then for Target do: cmd /c "SOMETHING",
where SOMETHING is replaced with your command. The only thing you would need to worry about is escaping all of the double quotes.
Then sequence the action after "Cost Finalize" in the execute sequence, and you should be good.
Haven't fully tested it, but should work.
Since the question is regarding InstallScript specifically, here's a simple function for this purpose.
// prototype void CmdExecute( STRING );
//---------------------------------------------------------------------------
// Function: CmdExecute
//
// Purpose: Asynchronusly execute a command line statement in the background
//
//---------------------------------------------------------------------------
function void CmdExecute( szCommand )
begin
LaunchApplication( "cmd.exe", "/C " + szCommand, "",
SW_HIDE, 0, LAAW_OPTION_NOWAIT );
end;
In your specific case, if you need to execute a series of commands, or if you run into other complications, I suggest using a batch file instead. If need be, you can write one on the fly (to have a pure installscript solution without adding files to the project), run it via LaunchApplication (or the variations of that) and then delete it afterwards.
As a nice little trick, I like to make such a batch file delete itself. How? At the end of it, add this:
cmd.exe /C timeout 30 >nul & del "%0" /q
This starts a separate process, so the batch file in no longer in use. The full 30 second delay isn't really necessary, but has proven to always work for me in the past. You can adjust that time, if you want it to hurry up and finish. The point is to make sure the batch can be deleted, which it can't be if it's in use.

Related Links

Let Setup.exe return '0'(success) when reinstalling - installshield
Limitations of InstallScript “Is(FILE_EXISTS, filename)”?
InstallScript Reboot after multiple prequisites
InstallScript detect app during upgrade?
InstallShield - Detect USB 3.0 Ports
Execute command line statement in installshield / installscript
InstallScript and machine.config
Need an example of /installfromweb command line switch for Installscript Project Setup.exe
How do you compare versions in InstallScript?
unInstallApplication of InstallShield is not working
How to find if the Installatoion was per user or per machine installation
During uninstallation the dll does not remove from system32 folder
Good resources on InstallScript

Categories

HOME
search
cobalt
developer-tools
pyqt4
python-multithreading
trac
vimdiff
reactive-programming
siddhi
emoji
intercom
cumulocity
fileserver
identity-management
drive
undertow
jquery-ias
question2answer
pagespeed
parcelable
game-theory
subclass
corenlp-server
record
html-encode
engine.io
raft
playframework-2.1
projects-and-solutions
verifiable-c
xv6
portforwarding
dbnull
movilizer
file-sharing
importerror
procfile
optimizely
fwrite
wcftestclient
x-ray
aquamacs
bbpress
reshape
mouseleave
rxtx
javafx-css
taocp
usart
segment-io
vulcanize
macaulay2
pre-build-event
swizzling
gcloud-ruby
turbo-prolog
highland.js
avisynth
rewrite
doctype
canalyzer
finalbuilder
dulwich
botan
ansi
fail2ban
document-repository
mobility
renderer
android-audiorecord
high-resolution
mysql-error-1044
code-duplication
video-codecs
os.system
cross-database
lr
http-daemon
twitterizer
cloudfiles
metaweblog
dot-emacs
openfaces
build-environment
purepdf
asynchronous-wcf-call
xpsdocument

Resources

Encrypt Message