问题描述
Access Get denied from credential remote access install exe file
捕获时捕获(Win32Exception)
错误消息>>拒绝访问。
我已将用户名,密码和域名输入StartInfo以便管理员登录。
因此用户可以通过单击按钮自动安装exe.file。
有什么建议可以解决这个问题吗?需要帮助!!!
我尝试过:
Capture at catch (Win32Exception)
Error message >> Access Denied.
I already put in the the username, password, and domain to StartInfo for admin login.
So the user can auto install the exe.file with single button click.
Any recommendation to solve this problem ? Need HELP !!!
What I have tried:
<pre lang="c#">
public static void GiveLogOnAsAServiceRights(string path,string username,string password,string domain,string computer,string args)
{
尝试
{
string tempPathForExe =//这是来自服务器路径(我关闭它);
string ntRightsTempFileName =//这是安装程序;
string fullNtRightsTempPath = Path.Combine(tempPathForExe,ntRightsTempFileName);
//系统。 IO.Directory.CreateDirectory(tempPathForExe);
流程objProcess = new Process();
objProcess .StartInfo.Arguments = @\\+ computer + - u+ domain +\\+ username + - p+ password + - i -d -h+ - accepteula +路径+ + args;
objProcess.StartInfo.RedirectStandardOutput = true;
if(!string.IsNullOrEmpty(username))
objProcess.StartInfo.UserName = username;
if(!string.IsNullOrEmpty(password))
{
objProcess.StartInfo.Password = new System.Security.SecureString ();
char [] passwordChars = password.ToCharArray();
foreach(charc in passwordChars)
objProcess.StartInfo.Password .AppendChar(c);
}
objProcess.StartInfo.Domain =penang;
objProcess.StartInfo.RedirectStandardError = true;
objProcess.StartInfo.RedirectStandardInput = true;
objProcess.StartInfo.CreateNoWindow = true;
objProcess.StartInfo.UseShellExecute = false;
objProcess.StartInfo.Verb =runas;
objProcess.StartInfo.FileName = fullNtRightsTempPath;
objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
// string connectionString = string.Empty;
//在接下来的两个函数中,应该弹出一个控制台并告诉我它在做什么......但它没有t $ / b
objProcess.Start();
objProcess.WaitForExit();
if(objProcess.HasExited )
{
//System.IO.File.Delete(fullNtRightsTempPath);
objProcess.Close();
返回;
}
}
catch(Win32Exception w32E)
{
//这个过程没有开始。
Console.WriteLine(w32E);
}
}
protected void Button1_Click (对象发送者,EventArgs e)
{
GiveLogOnAsAServiceRights(this is path dicratory,ansontay,1232312313,malaysia,HostnameAndService,) ; //计算机名称(HostnameAndService)
}
public static void GiveLogOnAsAServiceRights(string path, string username, string password, string domain, string computer, string args)
{
try
{
string tempPathForExe = " // This is from server path (i close it)";
string ntRightsTempFileName = "//this is the installer";
string fullNtRightsTempPath = Path.Combine(tempPathForExe, ntRightsTempFileName);
//System.IO.Directory.CreateDirectory(tempPathForExe);
Process objProcess = new Process();
objProcess.StartInfo.Arguments = @"\\" + computer + " -u " + domain + "\\" + username + " -p " + password + " -i -d -h " + "-accepteula " + path + " " + args;
objProcess.StartInfo.RedirectStandardOutput = true;
if (!string.IsNullOrEmpty(username))
objProcess.StartInfo.UserName = username;
if (!string.IsNullOrEmpty(password))
{
objProcess.StartInfo.Password = new System.Security.SecureString();
char[] passwordChars = password.ToCharArray();
foreach (char c in passwordChars)
objProcess.StartInfo.Password.AppendChar(c);
}
objProcess.StartInfo.Domain = "penang";
objProcess.StartInfo.RedirectStandardError = true;
objProcess.StartInfo.RedirectStandardInput = true;
objProcess.StartInfo.CreateNoWindow = true;
objProcess.StartInfo.UseShellExecute = false;
objProcess.StartInfo.Verb = "runas";
objProcess.StartInfo.FileName = fullNtRightsTempPath;
objProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
//string connectionString = string.Empty;
//During these next two functions, a console is supposed to pop up and tell me what it is doing... but it doesn't
objProcess.Start();
objProcess.WaitForExit();
if (objProcess.HasExited)
{
//System.IO.File.Delete(fullNtRightsTempPath);
objProcess.Close();
return;
}
}
catch (Win32Exception w32E)
{
// The process didn't start.
Console.WriteLine(w32E);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
GiveLogOnAsAServiceRights("this is path dicratory", "ansontay", "1232312313", "malaysia", HostnameAndService, ""); // Machine name (HostnameAndService)
}
推荐答案
这篇关于访问权限从凭据远程访问安装exe文件被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!