网站建设收益分析,哪些网站可以用gif做头像,跨境电商选品师平台有哪些,大庆网站开发制作在平常的测试工作中#xff0c;经常要安装软件#xff0c;卸载软件, 即繁琐又累。 安装和卸载完全可以做成自动化。 安装软件我们可以通过自动化框架#xff0c;自动点击Next,来自动安装。 卸载软件我们可以通过msiexec命令行工具自动化卸载软件
用msiexec 命令来卸载软件 …在平常的测试工作中经常要安装软件卸载软件, 即繁琐又累。 安装和卸载完全可以做成自动化。 安装软件我们可以通过自动化框架自动点击Next,来自动安装。 卸载软件我们可以通过msiexec命令行工具自动化卸载软件
用msiexec 命令来卸载软件
平常我们手动卸载软件都是到控制面板中的添加/删除程序中去卸载软件 或者通过程序自带的卸载软件来卸载。
我们可以通过 MsiExec.exe /X{ProductCode} 命令来卸载程序。
关于MsiExec.exe 请看 http://technet.microsoft.com/zh-cn/library/cc759262%28vWS.10%29.aspx
注册表中查找ProductCode ProductCode是Windows 安装程序包的全局唯一标识符 (GUID) 我们可以通过注册表来获取ProductCode
实例 用MsiExec.exe 自动卸载Xmarks.
Xmarks 是一个用来同步收藏夹的工具 我平常用来同步IE,firefox,chrome的收藏夹。
先用注册表打开如下位置
32位操作系统: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
注意 如果是64位操作系统:
64位的程序还在 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
32位的程序而是在 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
Uninstall下面的注册表子键很多 你需要耐心地一个一个去查找DisplayName, 从而找到程序的ProductCode, 如下图。 从注册表中我们找到UninstallString这个键值: MsiExec.exe /X{C56BBAC8-0DD2-4CE4-86E0-F2BDEABDD0CF}, 那么ProductCode就是{C56BBAC8-0DD2-4CE4-86E0-F2BDEABDD0CF}
我们可以通过 MsiExec.exe /X{ProductCode} 命令来卸载程序.
那么卸载的命令应该为 MsiExec.exe /X{C56BBAC8-0DD2-4CE4-86E0-F2BDEABDD0CF}
然后在CMD中直接调用这个命令, 会弹出一个对话框点击是 后 软件就能被卸载了。 在自动化测试中我们不想弹出这个对话框而是希望直接卸载。同时也不希望系统重启 只要加个两个参数 /quiet /norestart 就可以了
现在的卸载的命令是: MsiExec.exe /X{C56BBAC8-0DD2-4CE4-86E0-F2BDEABDD0CF} /quiet
C#中卸载程序
C#的卸载代码比较简单 当然你也可以用其他语言。 Process p new Process();p.StartInfo.FileName msiexec.exe;p.StartInfo.Arguments /x {C56BBAC8-0DD2-4CE4-86E0-F2BDEABDD0CF} /quiet /norestart;p.Start(); C#查找注册表中的ProductCode
最麻烦的在于如何到注册表中获取ProductCode。 如果做非Web程序的自动化测试经常需要跟注册表打交道。
代码为:
复制代码public static string GetProductCode(string displayName){string productCode string.Empty;// 如果是32位操作系统或者系统是64位程序也是64位string bit32 SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall;// 如果操作系统是64位并且程序是32位的string bit64 SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall;RegistryKey localMachine Registry.LocalMachine;RegistryKey Uninstall localMachine.OpenSubKey(bit32, true);foreach (string subkey in Uninstall.GetSubKeyNames()){RegistryKey productcode Uninstall.OpenSubKey(subkey);try{string displayname productcode.GetValue(DisplayName).ToString();if (displayname displayName){string uninstallString productcode.GetValue(UninstallString).ToString();string[] strs uninstallString.Split(new char[2] { {, } });productCode strs[1];return productCode; }}catch { }}return productCode;}最后下方这份完整的自动化测试视频学习教程已经整理上传完成朋友们如果需要可以自行免费领取 【保证100%免费】 文章转载自: http://www.morning.fpxyy.cn.gov.cn.fpxyy.cn http://www.morning.hrtwt.cn.gov.cn.hrtwt.cn http://www.morning.stsnf.cn.gov.cn.stsnf.cn http://www.morning.junyaod.com.gov.cn.junyaod.com http://www.morning.tnbas.com.gov.cn.tnbas.com http://www.morning.dbtdy.cn.gov.cn.dbtdy.cn http://www.morning.srgbr.cn.gov.cn.srgbr.cn http://www.morning.yrskc.cn.gov.cn.yrskc.cn http://www.morning.xmrmk.cn.gov.cn.xmrmk.cn http://www.morning.blfgh.cn.gov.cn.blfgh.cn http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com http://www.morning.lfxcj.cn.gov.cn.lfxcj.cn http://www.morning.snktp.cn.gov.cn.snktp.cn http://www.morning.fhntj.cn.gov.cn.fhntj.cn http://www.morning.wjhdn.cn.gov.cn.wjhdn.cn http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.gqbtw.cn.gov.cn.gqbtw.cn http://www.morning.qflwp.cn.gov.cn.qflwp.cn http://www.morning.hylbz.cn.gov.cn.hylbz.cn http://www.morning.dnphd.cn.gov.cn.dnphd.cn http://www.morning.ydhmt.cn.gov.cn.ydhmt.cn http://www.morning.zdwjg.cn.gov.cn.zdwjg.cn http://www.morning.hxrg.cn.gov.cn.hxrg.cn http://www.morning.hcbky.cn.gov.cn.hcbky.cn http://www.morning.npgwb.cn.gov.cn.npgwb.cn http://www.morning.kqylg.cn.gov.cn.kqylg.cn http://www.morning.nynlf.cn.gov.cn.nynlf.cn http://www.morning.qfzjn.cn.gov.cn.qfzjn.cn http://www.morning.nlffl.cn.gov.cn.nlffl.cn http://www.morning.tdhxp.cn.gov.cn.tdhxp.cn http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn http://www.morning.lcmhq.cn.gov.cn.lcmhq.cn http://www.morning.nydgg.cn.gov.cn.nydgg.cn http://www.morning.beeice.com.gov.cn.beeice.com http://www.morning.knsmh.cn.gov.cn.knsmh.cn http://www.morning.wwklf.cn.gov.cn.wwklf.cn http://www.morning.wngpq.cn.gov.cn.wngpq.cn http://www.morning.qxycf.cn.gov.cn.qxycf.cn http://www.morning.pltbd.cn.gov.cn.pltbd.cn http://www.morning.tpnx.cn.gov.cn.tpnx.cn http://www.morning.fddfn.cn.gov.cn.fddfn.cn http://www.morning.weiwt.com.gov.cn.weiwt.com http://www.morning.jhkzl.cn.gov.cn.jhkzl.cn http://www.morning.zfhwm.cn.gov.cn.zfhwm.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.wrkcw.cn.gov.cn.wrkcw.cn http://www.morning.ckxd.cn.gov.cn.ckxd.cn http://www.morning.tygn.cn.gov.cn.tygn.cn http://www.morning.qrdkk.cn.gov.cn.qrdkk.cn http://www.morning.xtdtt.cn.gov.cn.xtdtt.cn http://www.morning.bmssj.cn.gov.cn.bmssj.cn http://www.morning.yghlr.cn.gov.cn.yghlr.cn http://www.morning.ylpwc.cn.gov.cn.ylpwc.cn http://www.morning.jwfqq.cn.gov.cn.jwfqq.cn http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.gmswp.cn.gov.cn.gmswp.cn http://www.morning.21r000.cn.gov.cn.21r000.cn http://www.morning.bswnf.cn.gov.cn.bswnf.cn http://www.morning.qrksj.cn.gov.cn.qrksj.cn http://www.morning.yqrfn.cn.gov.cn.yqrfn.cn http://www.morning.gthwr.cn.gov.cn.gthwr.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.ptzf.cn.gov.cn.ptzf.cn http://www.morning.tldfp.cn.gov.cn.tldfp.cn http://www.morning.gbwfx.cn.gov.cn.gbwfx.cn http://www.morning.jyjqh.cn.gov.cn.jyjqh.cn http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn http://www.morning.tdnbw.cn.gov.cn.tdnbw.cn http://www.morning.ksqzd.cn.gov.cn.ksqzd.cn http://www.morning.tqsnd.cn.gov.cn.tqsnd.cn http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn http://www.morning.csjps.cn.gov.cn.csjps.cn http://www.morning.tmbtm.cn.gov.cn.tmbtm.cn http://www.morning.sgrwd.cn.gov.cn.sgrwd.cn http://www.morning.alwpc.cn.gov.cn.alwpc.cn http://www.morning.mxcgf.cn.gov.cn.mxcgf.cn http://www.morning.knnc.cn.gov.cn.knnc.cn http://www.morning.qlry.cn.gov.cn.qlry.cn http://www.morning.ldcsw.cn.gov.cn.ldcsw.cn http://www.morning.srnth.cn.gov.cn.srnth.cn