我有一个client.exe可执行文件,它将用以" autoupdate-client.exe开头的文件替换自己。 例如:如果client.exe运行且autoupdate-client.exe在同一文件夹中,则程序将删除client.exe并将autoupdate-client.exe重命名为client.exe。以下代码在widows中实现:
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之后 catch {file delete -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 :(得分:0)
对于Windows,您需要执行以下步骤:
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
编辑:
Windows没有执行权限的概念。 {{1}}命令可能没有按照您的想法进行。