当调用CreateFile()函数时,它返回错误代码0x5,这意味着访问被拒绝。任何人都可以帮忙解决这个问题吗?
注意:CreateFile()读取快照的路径,文件路径是\?\ globalroot \ device \ harddiskvolumeshadowcopy35 \ program files \ common files \ microsoft shared \ web server extensions \ 12 \ admisapi。
非常感谢。
答案 0 :(得分:0)
您可以手动创建该文件吗?这很可能是一个许可问题。
答案 1 :(得分:0)
这意味着您没有足够的权限从此文件中读取。检查文件权限。
答案 2 :(得分:0)
访问被拒绝,您的应用程序在哪里尝试创建文件?如果它在程序文件等中,可能是因为它的Windows 7和用户无法创建它而不首先提升权限。此外,请确保它在您认为的位置创建它。
答案 3 :(得分: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);