4

My .BAT has one Install Shield line that errors out with invalid switch /s, unless it is run in a separate command prompt. I'm new to all this, and all I can think is that it's because it is a different syntax. Is there a way to get this to run in the same batch as the rest of the install?

This is the line in Question:

    START /wait %desktop%\Serverx64\CDImage_1100_1003a\setup.exe /s /a /s /sms /f1c:\Temp\setup.iss

And this is my .BAT:

@echo off
@echo Installing SQL

MD C:\tempdasql

COPY ConfigurationFile.ini C:\tempdasql > nul
SQLEXPRWT_x64_ENU /ConfigurationFile="C:\tempdasql\ConfigurationFile.ini"
@echo SQL Installed
@echo:

@echo Installing 2005 BC
MSIEXEC /i SQLServer2005_BC_x64.msi /qb
@echo Installed 2005 BC
@echo:

DEL C:\tempdasql\ConfigurationFile.ini
RD C:\tempdasql

TIMEOUT /T 3
@echo:
@echo Installing WinRAR

SET desktop="%userprofile%\Desktop"

START "WinRAR" /wait %desktop%\Serverx64\winrar\wrar393.exe /s

SET winrar="C:\program Files\WinRAR\WinRAR.exe"

MD %userprofile%\Desktop\Serverx64\CDImage_1100_1003a\
@echo Extracting Foo
@echo:

%winrar% x %desktop%\Serverx64\CDImage_1100_1003a.iso %desktop%\Serverx64\CDImage_1100_1003a\

TIMEOUT /T 3
@echo:
@echo Installing Foo

MD C:\Temp

COPY %desktop%\Serverx64\Setup.iss C:\Temp\ >nul


START /wait %desktop%\Serverx64\CDImage_1100_1003a\setup.exe /s /a /s /sms /f1c:\Temp\setup.iss

DEL C:\Temp\setup.iss
RD C:\Temp

Copy C:\Foo\msvcr71.dll C:\Foo\Support\ >nul
START C:\Foo\Support\Pmtools.exe
Cœur
  • 37,241
  • 25
  • 195
  • 267
ThexTallxDude
  • 137
  • 1
  • 1
  • 11
  • 2
    Put paths in between `""` and add an empty string `""` between `start` and `/wait`... – aschipfl Jun 24 '16 at 18:14
  • So that did it. I started learning all this yesterday, so sorry if it was a stupid question. Why did that fix it, was it reading my filepath as the "" after START, rather than the .exe? – ThexTallxDude Jun 24 '16 at 18:33
  • 2
    `start` considers the first set of quotes it finds to be the title of the window that it opens, regardless of the location of those quotes. – SomethingDark Jun 24 '16 at 18:42
  • 2
    It's not a stupid question! Putting quotes around paths avoids trouble with spaces or some special characters in them; the empty string `""` is interpreted by `start` as a window title; if you do not place it, `start` might interprete something else as a title, and the remaining command line appears incomplete then... – aschipfl Jun 24 '16 at 18:46
  • Okay, so along that same line of thought with spacing, should I place strings with %userprofile% in quotes, in case the username has a space, ow will it recognize it properly without? And thanks so much for the help, coding seems like fun, I just never spent the time to learn before now – ThexTallxDude Jun 24 '16 at 18:59
  • @ThexTallxDude, you want to quote the entire path. Not just the variable. – Squashman Jun 24 '16 at 19:29
  • Yeah, but you want it quoted, regardless of whether or not the variable has a space, because the return may have the space, right? – ThexTallxDude Jun 24 '16 at 19:32
  • I recommend to always quote paths as it does never harm, no matter if it is a literal path (e. g., `"C:\TEMP\example.txt"`) or it contains variables (e. g., `"%USERPROFILE%\Documents"`). – aschipfl Jun 26 '16 at 23:15

1 Answers1

6

Fix was provided by Aschipfl. Placing a "" after START to create an empty string resolved the issue. Without the string following the START command, the batch was incorrectly processing my filepath and switches.

ThexTallxDude
  • 137
  • 1
  • 1
  • 11
  • 1
    To clarify, the "" is needed because the START command requires a title for the cmd window if you want to pass a command. The title can be made blank by using "" as is suggested above. The syntax is: start "Title" echo Hello, world! This will open a new cmd window titled "Title" and write out the text "Hello, world!" – Emanuel Lindström Apr 30 '19 at 13:37