I am writing a small utility program in IronPython to install applications on remote machine using managementclass which uses WMI.
我正在IronPython中编写一个小实用程序,使用使用WMI的管理类在远程机器上安装应用程序。
Now, the script would install an application on Machine_B from Machine_A, it works fine as long as you have the msi file on the local drive of the Target machine (Machine_B, in this case). I want to be able to do same thing with .msi file being on the Host (Machine_A) machine.
现在,该脚本将从Machine_A在Machine_B上安装应用程序,只要您在目标计算机的本地驱动器上有msi文件(在本例中为Machine_B),它就可以正常工作。我希望能够在主机(Machine_A)机器上使用.msi文件做同样的事情。
network_scope = r"\\%Machine_B\root\cimv2"
scope = ManagementScope(network_scope, options)
scope.Connect()
mp = ManagementPath("Win32_Product")
ogo = ObjectGetOptions()
mc = ManagementClass(scope, mp, ogo)
inParams = mc.GetMethodParameters ("Install")
inParams["PackageLocation"] = r"C:\installs\python-3.1.1.msi"
inParams["AllUsers"] = True
retVal = mc.InvokeMethod ("Install", inParams, None)
print retVal ["ReturnValue"].ToString()
PROBLEM :
问题:
[Machine A] --- Where I am running the script, and want to host the .msi file
[Machine B] --- where I want to install the application
[机器A] ---我在运行脚本的地方,想要托管.msi文件[机器B] ---我想在哪里安装应用程序
So, How can I define the UNC path for local machine ? what will be inParams["PackageLocation"] = ??
那么,如何为本地机器定义UNC路径?什么是inParams [“PackageLocation”] = ??
1 个解决方案
#1
2
Why not have your script copy the file to the administrative share C$ of the target machine, then optionally delete it when done? Installing from a local .msi is much faster than over-the-network reads of the .msi database continually.
为什么不让您的脚本将文件复制到目标计算机的管理共享C $,然后选择在完成后将其删除?从本地.msi安装比.msi数据库的网络连续读取要快得多。
#1
2
Why not have your script copy the file to the administrative share C$ of the target machine, then optionally delete it when done? Installing from a local .msi is much faster than over-the-network reads of the .msi database continually.
为什么不让您的脚本将文件复制到目标计算机的管理共享C $,然后选择在完成后将其删除?从本地.msi安装比.msi数据库的网络连续读取要快得多。