두 파일을 비교하기 위해 JavaScript를 사용하여 PowerShell 명령을 실행합니다. 결과는 텍스트 파일로 저장됩니다.JavaScript/PowerShell : 두 파일을 비교하고 결과를 텍스트 파일에 저장
function RunPowerShell() { var CommandPS= ' $File1 = Get-Content
"C:\\Test\\test1.txt"; $File2= Get-Content
"C:\\Test\\test2.txt";Compare-Object $File2 $File1 -PassThru
"C:\\Test\\Results.txt"';
var CmdCommand= 'cmd /c PowerShell '+ CommandPS;
}
RunPowerShell();
이 코드는 정상적으로 실행됩니다. 내가 변수 ("-PassThru> 결과")를 포함하는 파워 쉘 코드를 변경하는 경우
var AssignedNumber=1 var
Results='C:\\Test\\Results'+'_'+AssignedNumber+'.txt';
, 내 스크립트가 아무것도되지 않습니다 그러나, 나는 변수에 따라 동적으로 내 RESULTS.TXT 파일 이름을 지정해야 ("결과"에 나열된 파일이 생성되지 않음) : 어떤 도움에 감사드립니다
function RunPowerShell() { var CommandPS= ' $File1 = Get-Content
"C:\\Test\\test1.txt"; $File2= Get-Content
"C:\\Test\\test2.txt";Compare-Object $File2 $File1 -PassThru >
Results;
var CmdCommand= 'cmd /c PowerShell '+ CommandPS;
}
RunPowerShell();
,
감사
양자 물리학에서 Java를 알지 못하지만, PowerShell이 출력 파일을 생성 한 후에 출력 파일의 이름을 바꿀 수는 없습니까? – TheMadTechnician
코드 서식을 업데이트하려고했습니다. 두 코드 코드가'}' – Matt
'}' '이 (가) 추가되지 않았습니다. 감사합니다. – user3566591