简体   繁体   English

使用 WMI C# 读/写远程文件

[英]Read/Write Remote File using WMI C#

I need to read and write(update) some remote machine file.I am able to find the remote file using WMI(System.Management) but not able to do read or updation on that.我需要读取和写入(更新)一些远程机器文件。我能够使用 WMI(System.Management) 找到远程文件,但无法对其进行读取或更新。

Any help would be appreciated.任何帮助,将不胜感激。

Thanks谢谢

Himanshu喜满树

The WMI doesn't have any class (or method) to read or write the content of files. WMI 没有任何类(或方法)来读取或写入文件的内容。 You may only retrieve the metadata (FileName, Date, Size) of the files using CIM_DataFile , or do tasks like Copy , Rename , Delete or Compress files.您只能使用CIM_DataFile检索文件的元数据(文件名、日期、大小),或者执行复制重命名删除压缩文件等任务。

First check your file access in premmisions and set user "Everyone" to Full Control then try it again.首先检查您的文件访问权限并将用户“每个人”设置为完全控制,然后再试一次。完全访问

RRUZ is correct: WMI cannot copy or create files over a network. RRUZ 是正确的:WMI无法通过网络复制或创建文件。 This is because it would require credential "hopping": http://msdn.microsoft.com/en-us/library/windows/desktop/aa389288%28v=vs.85%29.aspx这是因为它需要凭据“跳跃”: http : //msdn.microsoft.com/en-us/library/windows/desktop/aa389288%28v=vs.85%29.aspx

However, a workaround was recently created by Stackoverflow.com user Frank White in C#, and the WMI logic ports directly to VBS.但是,Stackoverflow.com 用户 Frank White 最近在 C# 中创建了一个解决方法,并将 WMI 逻辑直接移植到 VBS。 Here's his solution: WMI remote process to copy file这是他的解决方案: WMI remote process to copy file

I ported it to a fully working VBScript: https://stackoverflow.com/a/11948096/1569434我将它移植到一个完全工作的 VBScript: https : //stackoverflow.com/a/11948096/1569434

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM