2017-10-12 8 views
2

나는 https://powerbi.microsoft.com/en-us/downloads/

에서 Powerbi 32 bit64 bit MSI 파일을 다운로드 및 스크립트 아래 만들었습니다.

$ScriptDir = (Split-Path $MyInvocation.MyCommand.Path) 


$MSIArguments = @(
    "/i" 
    "$ScriptDir\PBIDesktop.msi" 
    "/qn" 
# "/norestart" 
    "ACCEPT_EULA=1" 
) 

$MSIArguments2 = @(
    "/i" 
    "$ScriptDir\PBIDesktop_x64.msi" 
    "/qn" 
# "/norestart" 
    "ACCEPT_EULA=1" 
) 

$architecture=gwmi win32_processor | select -first 1 | select addresswidth 
if ($architecture.addresswidth -eq "64"){ 
    Start-Process "msiexec.exe" -ArgumentList $MSIArguments2 -wait 
} 
elseif ($architecture.addresswidth -eq "32"){ 
    Start-Process "msiexec.exe" -ArgumentList $MSIArguments -wait 
    } 
$ScriptDir 

스크립트는 source directory/$ScriptDir 사이에 공백이없는 경우에만 완벽하게 작동합니다. 예를 들어 소스 디렉토리가 c:/test 또는 c:/test_test/test이면 완벽하게 작동합니다. source directory/$ScriptDirC:\Users\Dell\Desktop\New folder PowerShell 스크립트 인 경우, 예를 들어

enter image description here

아래에 주어진

그러나 source directory/$ScriptDir에 공백이있는 경우, 그것은 MSI 옵션 오류로 중단

는 위의 메시지 .. 아직 설치시 중단됩니다.

가 나는 경로를 $ScriptDir

을 찾기 위해 스크립트의 끝에 에코 추가하고 그것은 나를 더 혼란하게 에코 결과 아래에 제공했다.

C:\Users\Dell\Desktop\New folder 

공간이있을 때 msiexec.exe가 인수를 실행할 수없는 이유를 잘 모릅니다.

내가 도울 수 있도록 도와주세요. 이유가 무엇일까요? $ ScriptDir에 공백이 있어도 어떻게이 문제를 해결할 수 있습니까?

답변

2

명령 줄에서 공백이있는 경로로 msiexec.exe (또는 대부분의 다른 명령)을 호출하려면 해당 경로를 따옴표로 묶어야합니다.

불행하게도,이 통과되고있는 시간에 의해 경로가 실제로 (당신의 해시 테이블에서 그들을 공급에도 불구하고.)를 가지고 있지 않습니다

을 이렇게하려면 ("") 일부는 따옴표를 탈출 제공 :

$MSIArguments = @(
    "/i" 
    """$ScriptDir\PBIDesktop.msi""" 
    "/qn" 
# "/norestart" 
    "ACCEPT_EULA=1" 
) 

경로의 경우 다음 세 가지 인용 부호로 묶습니다.

+1

정말 재미있었습니다 :) 이스케이프 된 따옴표 ("")를 사용하는 방법을 배웠습니다. – user879