2013-04-01 2 views
0

두 파일을 비교하고 일치하지 않는 값을 임시 파일에 저장했습니다. 이 link을 언급했습니다. 그런 다음 임시 파일에서 값을 읽고 원래 파일로 바꿉니다. 마지막으로 임시 파일을 삭제하려고했습니다. 임시 파일 삭제를 제외한 모든 프로세스가 정상적으로 작동합니다.NSIS에서 임시 파일이 삭제되지 않는 이유는 무엇입니까?

나는 다음 코드를 사용하고 있습니다 :

page custom twofilecompare 
page custom originalwrite 
     Function twofilecompare 
     FileOpen $0 "$INSTDIR\backup.properties" "r" 
     FileOpen $1 "$INSTDIR\orginal.properties" "r" 
     #IfFileExists "$INSTDIR\temp.properties" 0 +1 
     #Delete /REBOOTOK "$INSTDIR\temp.properties" 
     FileOpen $R0 "$INSTDIR\temp.properties" "w" 
     ClearErrors    

     loop: 
      FileRead $0 $2 
      ${If} $2 == "$\r$\n" 
      Goto loop 
      ${EndIf} 
      FindClose $0 


      FileRead $1 $3 
      IfErrors done   
      strcmp $2 $3 loop here 
      here: 
       FileWrite $R0 $2 
       Goto loop 

     done: 
      FileClose $0          
      FileClose $1 
      FileClose $R0 
     FunctionEnd 

     Function originalwrite 
    IfFileExists "$INSTDIR\temp.properties" 0 filenotfound 
    FileOpen $0 "$INSTDIR\temp.properties" "r" 
    loop: 
      FileRead $0 $1 
      IfErrors done 
      //do some stuff 

    done: 
     **IfFileExists "$INSTDIR\resource\temp.properties" 0 filenotfound 
     Delete /REBOOTOK "$INSTDIR\temp.properties"** 
    filenotfound: 
    MessageBox MB_OK "file not found" 
    FunctionEnd 

심지어 나는이 세 개의 파일을 수정할 수 캔트 [온도, 백업, 원본] 내가 수정하고 있는지 확인하십시오 "로 표시 프롬프트 메시지를 저장 클릭 also.If 수동으로 이 파일은 다른 프로그램을 열었습니다. " 파일 사용이 끝난 후 닫힌 파일을 사용했습니다. 심지어 나는이 코드 또한

Function .onInstSuccess 
IfFileExists "$INSTDIR\temp.properties" notfound 
MessageBox MB_OK "file exists" 
Delete /REBOOTOK $INSTDIR\temp.properties 
Goto done 
notfound: 
MessageBox MB_OK "file not found" 
Done: 
MessageBox MB_OK "file deleted" 
FunctionEnd 

을 시도하지만 임시 파일은 삭제되지 않습니다. 이 파일을 임시로 삭제하는 방법은 무엇입니까?

나를 도와 줄 사람이 있습니까? originalwrite 기능 FileClose

답변

1

사전에

덕분에 당신은 당신의 스크립트에서 관리자 권한을 요구하고 있는가? \ 프로그램 파일 : 당신이 관리자 권한은 C에서 텍스트 파일로 (편집 할 필요가있는 파일을 편집하려고하면 메모장 + + 같은

RequestExecutionLevel admin 

일부 응용 프로그램은 "이 파일이 다른 프로그램을 열 경우 확인하십시오"라는 메시지가 표시됩니다).

+0

감사합니다. 설치 한 후 설치 파일을 편집 할 수 없습니다.이 메시지는 다른 파일을 열었는지 확인하십시오. "하지만이 파일을 닫으면 어떻게됩니까?" – Ami

1

누락

관련 문제