what if the grave+quote is put in the line where $Source is declared?
tried that, unfortunately no.
I googled some stuff, and it looks like there are a couple of hacky ways around it, but nothing great.
take a look at Weekend Scripter: Understanding Quotation Marks in PowerShell - Scripting Blog
It talks about the differnce between single and double quotes
@Banderson
Try this for the source
$source = ‘“C:\Users\banderson\Desktop\A1 MasterComment.csv”’
That’s a [single quote] [double quote] full path with spaces [double quote] [ single quote]
edit: put the $Source var last on the process line, and have no closing quote
I was just doing that, except single then double for both, since the single acts as an escape character. Unfortunately, neither ways works. I think that specific argument won’t take strings.
edit, actually I am putting the location directly in the process line instead of using a variable. It tries to work without quotes, (get’s everything going but can’t find the location), but if I put quotes around it, bombs out right away. both singles, doubles, and combinations of single double
Let’s take a step back.
If you were typing this command out, it would be (line breaks added fore readability)
C:\Epicor\ERP10.2Client\Client\DMT.exe -User user -Pass password -Update -Import "Bill Of Operations" -Source "C:\Users\banderson\Desktop\A1 MasterComment.csv"
so everything from -User ....
through ...MasterComment.csv"
needs to be passed to the
-ArgumentList parameter
This should work:
$ArgList = "-User user -Pass password - Update -Import `"Bill Of Operations`" -Source `"C:\Users\banderson\Desktop\A1 MasterComment.csv`" "
Tried that. It doesn’t like the quotes on file location. It’s not the string in the variable itself. The argument for -Source doesn’t want to take anything with quotes in it.
yet it is okay with the "Bill of Operations"
after -Iimport ??
yeah, frustrates me too.
PS I:\> $DMTPath = "C:\Epicor\ERP10.2Client\Client\DMT.exe"
PS I:\> $User = "user"
PS I:\> $Pass = "password"
PS I:\> $source = '"C:\Users\banderson\Desktop\A1 MasterComment.csv"'
PS I:\> $ArgList = '-User $User -Pass $Pass -Update -Import "Bill Of Operations" -Source' + $Source
PS I:\>
PS I:\>
PS I:\> Echo $ArgList
-User $User -Pass $Pass -Update -Import "Bill Of Operations" -Source"C:\Users\banderson\Desktop\A1 MasterComment.csv"
PS I:\>
The above builds $ArgList such that you don’t need quotes on your “process-start” line
Still file not found. The location Bombs out at the space.
what about lower case tilde before each space?
$source = “C:\Users\banderson\Desktop\A1(lower case tilde) MasterComment.csv”
Just so we’re on the same page,
Entering the following on a command line, would work:
C:\Epicor\ERP10.2Client\Client\DMT.exe -User user -Pass password -Update -Import "Bill Of Operations" -Source "C:\Users\banderson\Desktop\A1 MasterComment.csv"
.
.
.
Does entering in the PS
Start-Procss -Wait -FilePath $DMTPath -ArgumentList 'C:\Epicor\ERP10.2Client\Client\DMT.exe -User user -Pass password -Update -Import "Bill Of Operations" -Source "C:\Users\banderson\Desktop\A1 MasterComment.csv" '
work?
no this does not
wait, command line. I thought you meant in Power shell. I haven’t tried it in command line.
That was just executing the DMT.exe. If that failed then it’s not a PowerShell thing.
(you did replace user
and password
, right?)
I gotta run… but one last thing…
From MS’s technical documentation, they provide the following example
PS C:\> Start-Process -FilePath "$env:comspec" -ArgumentList "/c dir `"%systemdrive%\program files`""
Granted there are new no Variables in what is passed to ArgumentList, but it does show quote bounded string “%systemdrive%\program files”
Edit:
another way to do the same is:
PS C:\> Start-Process -FilePath "$env:comspec" -ArgumentList "/c","dir","`"%systemdrive%\program files`""
Seems the commas concatenate strings together (an no spaces need between the /c and dir
the command line works.
Can a command line run a playlist?