2014-07-23 4 views
0

컴퓨터에서 프로그램 목록을 가져 와서 해당 프로그램 목록을 공유 서버의 텍스트 파일에 업로드하려고합니다. 코드와 출력은 아래와 같습니다. 코드 줄을 실행하면 wmic /output:C:\Users\%username%\Desktop\temp.txt product get name,version pause, Invalid file name. 오류가 발생합니다. 누군가이 오류를 없애는 방법을 가르쳐 줄 수 있다면 정말 고맙겠습니다.WMIC 리디렉션 : 잘못된 파일 이름 오류

코드 :

echo. >> "N:\Individual Files\Jerry\Projects\TroubleshootingPCIssues\audits\Audit of Software Programs on Each Computer.txt" 
echo. >> "N:\Individual Files\Jerry\Projects\TroubleshootingPCIssues\audits\Audit of Software Programs on Each Computer.txt" 
echo %computername% >> "N:\Individual Files\Jerry\Projects\TroubleshootingPCIssues\audits\Audit of Software Programs on Each Computer.txt" 
echo -------------------------------------------------------------------------------------- >> "N:\Individual Files\Jerry\Projects\TroubleshootingPCIssues\audits\Audit of Software Programs on Each Computer.txt" 
wmic /output:C:\Users\%username%\Desktop\temp.txt product get name,version 
pause 
type "C:\Users\%username%\Desktop\temp.txt">>"N:\Individual Files\Jerry\Projects\TroubleshootingPCIssues\audits\Audit of Software Programs on Each Computer.txt" 
pause 

출력 : (2 빈 줄의 comuter에 이름 및 점선) (아직 프로그램 이름 없음 목록)

` 


ANTHEMDESKTOP23 
-------------------------------------------------------------------------------------- ' 
+0

'C 않습니다 : \ 사용자 \ % 사용자 이름 % \ Desktop' 존재 하는가? 그렇지 않을 수도 있습니다 - 사용자 프로필은 항상'C : \ Users'에있는 것은 아니며 폴더 이름은 항상'% username %'(도메인은 일련 번호처럼 추가 될 수 있습니다)이 아닙니다. '% USERPROFILE % \ Desktop'을 시도하십시오. –

+0

제 경우에는 존재합니다. 내 코드의 5 행에서'C : \ Users \ % username % \ Desktop \ temp.txt' 주위에 따옴표를 넣는 것을 잊어 버렸습니다. 귀하의 우려와 의견을 주셔서 감사합니다. – pbars23

답변

1

이 문제 해결에 도움이 되었습니까? %username%에는 공백이 포함될 수 있으며 그 정보를 제공해야합니다. 앤드류의 의견으로

wmic /output:"C:\Users\%username%\Desktop\temp.txt" product get name,version 

이 위보다 더 신뢰할 수있다 :

wmic /output:"%userprofile%\Desktop\temp.txt" product get name,version 
+0

감사합니다. 나는 C : \ Users \ % username % \ Desktop \ temp.txt 주위에 따옴표를 넣는 것을 잊어 버렸다. 그 코드 줄에 쉼표를 넣을 때. 내 스크립트가 작동합니다. 더 신뢰할 수있는 방법을 사용하여 당신도 설명했다. – pbars23

관련 문제