Run app as administrator in c#

0 thích 0 không thích
1 lượt xem
đã hỏi 29 Tháng 8, 2023 trong Lập trình C# bởi nguyenthao (9,000 điểm)
public void ExecuteAsAdmin(string fileName)
{
	new Process
	{
		StartInfo = 
		{
			FileName = fileName,
			UseShellExecute = true,
			Verb = "runas"
		}
	}.Start();
}

    

2 Câu trả lời

0 thích 0 không thích
đã trả lời 29 Tháng 8, 2023 bởi nguyenthao (9,000 điểm)
Đã test ok ngon lành
0 thích 0 không thích
đã trả lời 5 Tháng 9, 2023 bởi nguyenthao (9,000 điểm)
sửa nội dung 8 Tháng 9, 2023 bởi nguyenthao
Add the following line:

request.UseDefaultCredentials = true;
This will let the application use the credentials of the logged in user to access the site. If it's returning 403, clearly it's expecting authentication.

It's also possible that you (now?) have an authenticating proxy in between you and the remote site. In which case, try:

request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
Hope this helps.

https://github.com/miyakogi/pyppeteer/blob/dev/pyppeteer/page.py#L312:
...