0

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

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

非常感谢。

4

4 回答 4

0

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

于 2011-04-01T09:18:40.103 回答
0

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

于 2011-04-01T09:19:02.863 回答
0

访问被拒绝,您的应用程序在哪里尝试创建文件?如果它在程序文件等中,可能是因为它的 Windows 7 和用户在不首先提升权限的情况下无法创建它。另外,请确保它在您认为的位置创建它。

于 2011-04-01T09:22:07.187 回答
0
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);
于 2011-04-07T00:44:50.160 回答