MSIEXEC not installing when PROPERTY=value contains a space within quotes - windows

Trying to run this particular msiexec command in powershell is becoming an increasing source of frustration for me. When running the below command with the final 'Practice CS' removed, the command works great. As soon as I add 'Practice CS', the MSI help window appears and the command does not install. Also, simply deleting the space and trying with 'PracticeCS' also works. The space itself is killing the msi process. It is inside of quotes so it should work according to all help available.
msiexec /i PracticeCS.msi SHAREDFILESDIR='\\deployment.contoso.local\d$\Applications\Company\WinCSI\Practice CS\'
EDIT 1:
I got it to work with the invocation operator &. I am not sure why the below line works, but it did.
& msiexec /i "\\deployment.contoso.local\d$\Applications\company\wincsi\Practice CS\desktop\MSI\PracticeCS.msi" SHAREDFILESDIR=`"\\deployment.contoso.local\d$\Applications\company\wincsi\Practice CS`"
(imagine only one backtick at the end. cant get punctuation to display correctly)
Take note that the first /i file path works normally with just regular double quotes.
The path SHAREDFILESDIR worked when using the invocation operator combined with the backtick and double quotes ` and ". Using that at beginning and ending got the installer to work.
Anyone know why?

Related

how to use quote marks in a for loop in windows command line

Beginner's question here so I'd be grateful for a baby explanation.
I'm trying to create a concatenation text file that lists the files (with paths) in a certain folder, with the word "file" appended to the beginning of each line, as well as quotation marks. I want the text file to look like this:
file 'file:DriveLetter:\path\filename1.mp3'
file 'file:DriveLetter:\path\filename2.mp3'
etc
The command I'm running is as follows:
(for %i in (*.mp3) do #echo file 'file:%cd%\%i') > mylist.txt
But I receive the following error
%i') was unexpected at this time.
However, if I use double quotes instead of single, the command works. But this causes problems in my next step, which is to use ffmpeg to concatenate the files - it refuses to read the double quote marks.
Any advice is much appreciated. I'm open to an alternative method.
I just tried and everything is working fine. I believe that some character has been altered. Are you sure you're typing your command in your command prompt instead of using some editor (which does automatic modifications) and copying/pasting into a command prompt afterwards?

lua io.popen run program with space in path

I'm trying to get this program to start but I keep getting an error.
I've already tried to make the blockquotes [==[]==] around the string and "" around the program path but it still doesn't work.
local test = string.format([==["C:\Program Files (x86)\Audacity\audacity.exe" "F:\Aufnahme %s.%s.%s\ZOOM0001.WAV"]==], tag, monat, jahr)
print(test)
io.popen(test)
error when running the lua file
If I copy the command from the print(test) and use that in cmd.exe it works.
Thanks for the help :)
On Windows, you must enclose your command line (program + arguments) in additional outer-level quotes.
local test = string.format([==["C:\Program Files (x86)\Audacity\audacity.exe" "F:\Aufnahme %s.%s.%s\ZOOM0001.WAV"]==], tag, monat, jahr)
test = '"'..test..'"'
print(test)
io.popen(test)
When you are typing the command from keyboard in CMD.EXE window, then these additional quotes are added automatically by the code that is processing your keyboard input.
When you're using C function system or Lua functions os.execute, io.popen then you must add additional quotes manually.
This is how CMD.EXE works (and its design is full of not-very-logical decisions).

Windows Task Scheduler cannot run batch with special characters in filename

I have a batch script which makes a backup of my SQL databases. It runs perfectly when I manually run the script! The filename looks like SRVNAME_PRJ123!abc=CITY!Database=DBNAME
But when I create a scheduled task, it does not work! CMD says that SRVNAME_PRJ123!abc is not a command or cannot be found. As you can see after the first equal sign (=) in the filename everthing is truncated.
It seems like that the task scheduler thinks that the filename is command, but I need this special characters in the filename.
Is there a way to make this work?
I can replicate this behavior. I expected that quoting the filename would solve it, but apparently it doesn't. The only way I found so far to make this work is to escape the = sign in the filename by inserting a ^: SRVNAME_PRJ123!abc^=CITY!Database=DBNAME
Strangely enough, when running from a command prompt, quoting works, but escaping doesn't.

"was unexpected at this time."

I'm running this command on a batch file:
for %I in (*.txt *.doc) do copy %I c:\test2
...and it keeps returning:
I was unexpected at this time.
What is the cause of this error?
If you're running within a batch/cmd file, you need to double the % markers:
for %%i in (*.txt *.doc) do copy %%i c:\test2
The single % variant only works from the command line.
If being run from a batch file, variables need to be denoted with two percent signs, like %%I, only from the command line you use one
I ran across a case where I was getting this error from a file that was named *.cmd. The error arose when I tried to access the first argument to the batch command:
if %1 EQU ""
Once I put quotes around the symbol for the first argument, the warning message went away:
if "%1" EQU ""
Not a direct answer to the question, but if you encounter this message in any program, batch command, etc. then it's most likely related to your PATH containing " characters.
For instance, in Atom editor I was getting the message in the settings view.
"\"GNU was unexpected at this time
This was due to a different program putting in my PATH the following entry
...;C:\"Program Files"\"GNU ARM Embedded;..."
Because of that, the antislash character is read as escaped by some programs, which causes issues because then it's not a pathname delimiter but a simple character.
The solution for me was to remove those " from the PATH, and everything worked fine.
...;C:\Program Files\GNU ARM Embedded;...
PS: I have a doubt whether or not this can impact the original program (GNU ARM Embedded in this case) that maybe does not support spaces in pathnames. If somebody with more insight can clarify in the comments, I will update my post.
Hope this helps

How to set PATH to another variable value with spaces in Windows batch file

I've got a Windows batch script issue that I'm bashing my head against (no pun intended). The problematic script looks like this:
if defined _OLD_VIRTUAL_PATH (
set PATH=%_OLD_VIRTUAL_PATH%
)
When I run it and _OLD_VIRTUAL_PATH is set I get:
\Microsoft was unexpected at this time.
_OLD_VIRTUAL_PATH is a variable that was originally set from PATH and it contains spaces - I'm pretty sure that's the problem. But what's the solution? It runs successfully if I enclose it in quotes, but I don't think the entire value of the PATH variable is supposed to be in quotes.
Your problem here are not the spaces but rather a closing parenthesis. You are probably running a 64-bit system where the Program Files directory for 32-bit applications is Program Files (x86). In a parenthesized block in a batch file, the closing parenthesis ends the block, so the rest of the line causes a syntax error.
You have two ways to fix this:
1) Put the complete set argument in quotes. This causes the closing paren to not be recognized as end of block:
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
)
2) Don't use a block:
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
Well - I never knew about the defined operation in cmd scripts until just now...
Your script seems to work fine for me - which line exactly is producing the error?
You can also try:
if not "%_OLD_VIRTUAL_PATH%" == "" (
set PATH=%_OLD_VIRTUAL_PATH%
)
And believe me, if you're coming into Windows cmd scripting expecting it to be anything like what you have in bash, your head will be very much in pain, very soon. You might want to look into using some other scripting language (PowerShell, Python, PERL - anything) if cmd scripting isn't an absolute requirement. the biggest thing (maybe the only thing) that cmd scripting has going for it is that it's already installed on every Windows box.

Resources