远程计算机上本地计算机的 UNC 路径是什么?
我正在 IronPython 中编写一个小型实用程序,以使用使用 WMI 的管理类在远程计算机上安装应用程序。
现在,该脚本将从 Machine_A 在 Machine_B 上安装应用程序,只要目标计算机(在本例中为 Machine_B)的本地驱动器上有 msi 文件,它就可以正常工作。我希望能够对主机 (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()
问题:
[机器 A] --- 我运行脚本的位置,并且想要托管 .msi 文件
[机器 B] --- 我想要安装应用程序的位置
那么,如何定义本地机器的 UNC 路径? inParams["PackageLocation"] = ?? 会是什么?
I am writing a small utility program in IronPython to install applications on remote machine using managementclass which uses 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.
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
So, How can I define the UNC path for local machine ?
what will be inParams["PackageLocation"] = ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不让您的脚本将文件复制到目标计算机的管理共享 C$,然后在完成后选择将其删除?从本地 .msi 安装比通过网络持续读取 .msi 数据库要快得多。
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.