windows 使用python脚本在windows中卸载和安装程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3607640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uninstall and Install Programs in windows using python script
提问by Everest
Possible Duplicate:
Add/remove programs in Windows XP with Python script
I am a newbie in python and basically do windows sysadmin tasks and sometimes write batch script. However i am trying to learn python by implementing the scripts in windows tasks. The actual task i want to do is a follows: To remove acrobat reader or acrobat standard version and install acrobat professional. I also have to remove SAP client application from the machine and be able to run another SAP install.cmd file which then installs an updated version of SAP.could your or someone post me a more or less complete working script?
我是 python 的新手,基本上做 windows sysadmin 任务,有时编写批处理脚本。但是,我正在尝试通过在 Windows 任务中实现脚本来学习 Python。我想要做的实际任务如下:删除 acrobat 阅读器或 acrobat 标准版本并安装 acrobat 专业版。我还必须从机器上删除 SAP 客户端应用程序,并能够运行另一个 SAP install.cmd 文件,然后安装更新版本的 SAP。您或某人能否向我发布或多或少完整的工作脚本?
Thanks in advance – Everest
提前致谢 – 珠穆朗玛峰
回答by Katriel
To call a function as if you had entered it on the command line, use subprocess.Popen
. There are various scripting functions (copy, remove) in the os
and shutil
modules.
要像在命令行中输入一样调用函数,请使用subprocess.Popen
. os
和shutil
模块中有各种脚本功能(复制、删除)。