2017-10-23 4 views
0

client.exeの実行ファイルがあります。このファイルは "autoupdate-client.exe。 "で始まるファイルで置き換えられます。たとえば、client.exeが実行され、autoupdate-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> 

編集:

Windowsが実行権限の概念はありません。 file attributesコマンドは、あなたが考えるものを実行していない可能性があります。

+0

すべての '.exe'ファイルは、レジストリに設定されていないと言うポリシーがない限り、実行可能とみなされます。また、実行可能ファイルは(通常は)読み取り専用でロックされており、一部のアプリケーションやサービス(ウイルス対策ソフトウェアなど)でも多くのことに干渉することがあります。それは面倒で複雑です。 –

関連する問題