0

In my NSIS script, I have the following lines (Didn't turn the 1st line into a code block because it was too long and looked bad as 1 line):

Exec '"$BINDIR\SubscriberACD.exe" //IS//SubscriberACD --Install="$BINDIR\SubscriberACD.exe" --Description="Subscriber service with Apache Commons Daemon" --Jvm="$JVMDIR\jvm.dll" --Classpath="$CLASSESDIR\SubscriberACD.jar;$CLASSESDIR\jeromq-0.3.5.jar;$CLASSESDIR\jackson-databind-2.6.3.jar;$CLASSESDIR\jackson-core-2.6.3.jar;$CLASSESDIR\jackson-annotations-2.6.0.jar;$CLASSESDIR\management-core-util-4.1.2.jar;$CLASSESDIR\management-measurement-4.1.2.jar;$CLASSESDIR\management-measurement-checkpoint-writer-1.0.jar;$CLASSESDIR\jna-4.2.2.jar;$CLASSESDIR\jna-platform-4.2.2.jar" --StartMode=jvm --StartClass=SubscriberACD.Subscriber --StartMethod=windowsService --StartParams=start --StopMode=jvm --StopClass=SubscriberACD.Subscriber --StopMethod=windowsService --StopParams=stop --LogPath="$INSTDIR\SubscriberACD\logs" --StdOutput=auto --StdError=auto'

Sleep 5000

ExecWait '"sc" config SubscriberACD start=" auto"'

Somehow, when I look at my NSIS logs, I see the following:

Execute: "C:\Program Files (x86)\MyProduct\SubscriberACD\bin\SubscriberACD.exe" //IS//SubscriberACD --Install="C:\Program Files (x86)\MyProduct\SubscriberACD\bin\SubscriberACD.exe" --Description=" Subscriber service with Apache Commons Daemon" --Jvm="C:\Program Files (x86)\MyProduct\SubscriberACD\jdk7\jre\bin\server\jvm.dll" --Classpath="C:\Program Files (x86)\MyProduct\SubscriberACD\classes\SubscriberACD.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\jeromq-0.3.5.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\jackson-databind-2.6.3.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\jackson-core-2.6.3.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\jackson-annotations-2.6.0.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\management-core-util-4.1.2.jar;C:\Program Files (x86)\MyProduct\SubscriberACD\classes\management-measurement-4.1.2.jar;C:\PrograExecute: "sc" config SubscriberACD start= auto

Notice how NSIS combined the two lines and actually overwrote some of the content from the first line. Any ideas on on what is causing this? Does NSIS not like commands with long parameters?

Originally, I used ExecWait for my first command. When I was seeing the same problem, I switch to using Exec and then added a Sleep 5000 after that to sleep for 5 seconds since I thought it might have been a timing issue.

I double checked my quotation marks to make sure that they match.

SpartaSixZero
  • 2,183
  • 5
  • 27
  • 46

1 Answers1

2

NSIS has a 1024 character limit by default. I'm guessing when $INSTDIR is expanded you exceed that limit. You can download the large string build or execute a batch file instead:

Section
InitPluginsDir
FileOpen $0 "$PluginsDir\test.cmd" w
FileWrite $0 '@echo off$\n'
; Write out example command in pieces:
FileWrite $0 '"$sysdir\forfiles.exe"'
FileWrite $0 ' /P "$windir" /S'
FileWrite $0 ' /M "*shell32*"$\n'
FileClose $0
ExecWait '"$PluginsDir\test.cmd"'
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • I think switching to NSIS 3.0 is not an option for now as we have a release coming up quick so I'll try the batch file option. By the way, I'm new to NSIS and not really sure what the purpose of your NSIS code is. :) – SpartaSixZero Aug 02 '16 at 19:51
  • [Here](https://sourceforge.net/projects/nsis/files/NSIS%202/2.51/nsis-2.51-strlen_8192.zip/download) is the NSIS 2 special build. My batch file code has no real purpose, it was just an example showing you how to build and execute a batch file... – Anders Aug 02 '16 at 19:59
  • I was able to get around this max character length problem by reducing the total length of my string. Thanks – SpartaSixZero Aug 03 '16 at 14:24