首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用CreateFile()时访问被拒绝

调用CreateFile()时访问被拒绝
EN

Stack Overflow用户
提问于 2011-04-01 17:14:36
回答 4查看 2.6K关注 0票数 0

当调用CreateFile()函数时,它返回错误代码0x5,这意味着访问被拒绝。任何人都可以帮助解决这个问题吗?

注意: CreateFile()读取快照的路径,文件路径为\?\globalroot\device\harddiskvolumeshadowcopy35\program files\common files\microsoft \web server extensions\12\CreateFile and。

非常感谢。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-04-07 08:44:50

代码语言:javascript
复制
ConnectionOptions connection = new ConnectionOptions();

//just username, without domain name, otherwise, a "RPC is Unavaliable." exception will be thrown.
connection.Username = "testUser";

connection.Password = "testPassword";

//Allow privilege
connection.EnablePrivileges = true;

connection.Impersonation = ImpersonationLevel.Delegate;

connection.Authentication = AuthenticationLevel.Call;

//Neither ntdlmdomain or kerberoes, otherwise, a "Invalid Parameter." exception will be thrown.
connection.Authority = "ntlmdomain:MYDOMAIN";

//IP Address or host full name.
ManagementScope scope = new ManagementScope("\\\\myIPAddress\\root\\CIMV2", connection);

scope.Connect();

ManagementClass classInstance = new ManagementClass(scope,new ManagementPath("Win32_Process"), null);

ManagementBaseObject inParams = classInstance.GetMethodParameters("Create");

//Change it to your own execute file path
inParams["CommandLine"] = "myExecuteFilePath";

ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, null);
票数 0
EN

Stack Overflow用户

发布于 2011-04-01 17:18:40

您可以手动创建该文件吗?这很可能是权限问题。

票数 0
EN

Stack Overflow用户

发布于 2011-04-01 17:19:03

这意味着您没有足够的权限读取此文件。检查文件权限。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5511367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档