带有空格和参数的Powershell脚本路径

时间:2017-11-08 08:04:40

标签: c++ powershell

我正在使用{ "questions": [ { "questionId": "1", "questionText": "Create a function named \"add\" that adds 2 parameters", "testCase": "3,5", "expectedReturn": "8" "difficulty":"hard" "type":"general" }, { "questionId": "12", "questionText": "Write a function named \"subtract\" that takes two integers, and subtracts the second from the first.", "testCase": "10,3", "expectedReturn": "7" "difficulty":"medium" "type":"math" }, { "questionId": "88", "questionText": "Write a function named \"reverse\" that takes one parameter, a string t, and returns the string backwards.", "testCase": "hello", "expectedReturn": "olleh" "difficulty":"easy" "type":"string" }, { "questionId": "89", "questionText": "Write a function called \"greeting\" that takes in one string parameter, name, and returns the string \"Hello \" followed by the name.", "testCase": "Bob", "expectedReturn": "Hello Bob" "difficulty":"hard" "type":"for loop" //doesn't make sense, but just as an example }, { "questionId": "90", "questionText": "Write a function named isEvenOrOdd that takes in an integer n, and returns \"even\" if it is even, and \"odd\" if it is odd.", "testCase": "12", "expectedReturn": "even" }, { "questionId": "93", "questionText": "Write a function named \"addFiveDivideFive\" that takes in 5 integer parameters, adds them all together, and divides the sum by 5. Return this quotient.", "testCase": "10,5,15,25,35,50", "expectedReturn": "28" }, { "questionId": "94", "questionText": "Write a function called findLength that takes in a string parameter t, and returns the length of that string.", "testCase": "helloworld", "expectedReturn": "10" "difficulty":"easy" "type":"general" }, { "questionId": "95", "questionText": "Write a function named multiply that takes in two integers, and returns the product", "testCase": "3,5", "expectedReturn": "15" "difficulty":"hard" "type":"math" } ] } 从C ++代码运行PowerShell脚本。

但是我的脚本路径包含空格。我需要将一个参数传递给脚本。如果路径中没有空格,则代码可以正常工作。

createProcess

我尝试在路径周围添加引号但是它停止识别参数并发出意外的令牌错误:

CString sysCommand;
sysCommand.Format(_T("powershell.exe -executionpolicy unrestricted /C %s 
%s"), psFile, parameter);

0 个答案:

没有答案