我需要使用Internet Explorer浏览URL,然后通过TCL脚本使用taskkill关闭。我正在使用以下TCL脚本。
我的TCL脚本:
set data [open input_url.txt r]
set test [read $data]
foreach url $test {
exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url
after 2000
exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLORE.EXE /F
}
input_url.txt内容:
clickshare upload.com upload.to 10upload.com 123upload.pl 139pan.com 163pan.com
但是当我运行此脚本时,将打开带有第一个URL的浏览器。但在此之后什么也没发生。 2-3分钟后,如果我手动关闭浏览器,我会看到以下错误:
C:\Users\kumar\Desktop\test>tclsh stack_question.tcl
child process exited abnormally
while executing
"exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url"
("foreach" body line 2)
invoked from within
"foreach url $test {
exec "C:/Program Files/Internet Explorer/IEXPLORE.EXE" $url
after 2000
exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLO..."
(file "stack_question.tcl" line 3)
C:\Users\kumar\Desktop\test>
我可以使用taskkill.exe手动终止浏览器会话,如下所示:
C:\Users\kumar\Desktop\test>tclsh
% exec "C:/WINDOWS/System32/taskkill.exe" /IM IEXPLORE.EXE /F
SUCCESS: The process "iexplore.exe" with PID 3948 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 3744 has been terminated.
%
有人可以帮我解决这个问题吗?
提前致谢。
答案 0 :(得分:1)
似乎exec
在继续执行之前等待iexplore.exe
完成。为了允许立即返回使用start
命令:
exec cmd.exe /c start iexplore.exe $url
这将立即返回。