2017-10-23 2 views
0

client.exe 실행 파일이 있는데 "autoupdate-client.exe ."으로 시작하는 파일로 대체됩니다. 예 : client.exe가 실행되고 autoupdate-client 인 경우. . exe는 같은 폴더에 다음 프로그램이 client.exe가를 삭제하고 다음 코드는 과부로 구현 client.exe가하는 자동 업데이트-client.exe가 이름을 바꿀 것입니다 :TCL에서 파일 속성을 사용하여 파일에 대한 사용 권한 부여

if {[regexp -nocase \ 
"autoupdate-(.*)" \ 
[file tail [info nameofexecutable]] - binaryname]} { 
after 5000 
set dirname [file dirname [info nameofexecutabe] 
set targetname [file join $dirname $binaryname] 
catch {vfs::mk4::Unmount exe [info nameofexecutable]] 
file copy -force [infor nameofexecutable] $targetname 
catch {file attributes $targetname -permission 0755} 
exec $targetname {*}$argv & 
exit 0 
} else { 
set dirname [file dirname [infor nameofexecutable] 
set targetname [file join $dirname \ 
"autoupdate-[file tail [info nameofexecutablle]]}\ 
] 
if {[file exists $targetname]} { 

후 5000 캐치 {파일 삭제 - force $ targetname}

다음 오류가 발생합니다.

error copying "autoupdate-client.exe" to "client.exe": permission denied 
while executing " 
file copy -force [info nameofexecutable] $targetname" 

파일 특성 $ targetname -permission 0755가 오류를 발생시키는 것으로 의심됩니다. 가 나는 Windows 용

답변

0

에 권한을 줄 수있는 방법을 알고 싶어, 당신은 다음과 같은 단계를 수행해야합니다 : 이전 실행이 시간에 제거 할 수 있다는 보장은 없습니다

# Rename the original file to a new name. 
file rename -force client.exe client-old.exe 
# Rename (or copy) the new file to the target name. 
file rename -force autoupdate-client.exe client.exe 
# Now (try) to remove the old file 
catch { file delete -force client-old.exe } 

. 나중에 제거해야 할 수도 있습니다.

C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin>copy tclsh.exe t1.exe 
     1 file(s) copied. 
C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin>copy tclsh.exe t2.exe 
     1 file(s) copied. 
C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin>.\t1.exe 
% file rename -force t1.exe t1-old.exe 
% file rename -force t2.exe t1.exe 
% file delete -force t1-old.exe 
error deleting "t1-old.exe": permission denied 
% exit 
C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin>dir t*.exe 
Directory of C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin 
2017-10-23 10:37   453,579 t1-old.exe 
2017-10-23 10:37   453,579 t1.exe 
2017-10-23 10:37   453,579 tclsh.exe 
C:\Users\bll\Desktop\BallroomDJ\windows\64\tcl\bin> 

편집 :

윈도우가 실행 권한을 전혀 개념이 없습니다. file attributes 명령은 사용자가 생각하는대로 수행하지 않을 수 있습니다.

+0

모든'.exe' 파일은 레지스트리에 정책이 설정되어 있지 않은 한 실행 가능하도록 계산됩니다. 또한 실행 파일은 프로세스가 실행 중일 때 (일반적으로) 읽기 전용으로 잠겨 있으며 일부 응용 프로그램과 서비스 (예 : 바이러스 백신)도 많은 것을 방해 할 수 있습니다. 지저분하고 복잡합니다. –

관련 문제