Jump to content

C# Yazılımı Hakkında


titanpegasus
 Share

Recommended Posts

C# da bir proje yapıyorum. Fakat yönetici iziniyle başlaması gerekiyor. Bilgisayarda visual studio 2012 pro yüklü. App.manifest dosyasından require administrator yapıyorum. Clickonce desteklemiyor gibi bir uyarı çıkıyor. Bunu nasıl çözerim? 2. bir sorunda butona basıldığında cmd de bir komut gerçekleşiyor. Bu komutu yönetici olarak nasıl başlatırım?

Link to comment
Share on other sites

Programda windows 8.1 keyini hızlı girmek için slmgr.vbs çalıştırmak istiyorum.Akşam ekran görüntülerini yollarım. Textboxdaki keyi komutla birlikte cmdye yolluyor . Butonun kodu

 

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C" + " slmgr.vbs -ipk " + textbox1.text;
process.StartInfo = startInfo;
process.Start();

 

Çalışıyor ama yönetici olmadığı için yapılamadı diye uyarı çıkıyor. Bunu nasıl yönetici olarak yapabilirim?

Link to comment
Share on other sites

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C" + " slmgr.vbs -ipk " + textbox1.text;
startInfo.Verb = "runas";
process.StartInfo = startInfo;
process.Start();

Kodları böyle değiştirin ve manifest dosyanıza aşağıdaki satırı ekleyin..

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Link to comment
Share on other sites

Birde böyle deneyebilirmisin

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C" + " slmgr.vbs -ipk " + textbox1.text;
startInfo.Verb = "runas";
startInfo.UseShellExecute = true;
process.StartInfo = startInfo;
process.Start();
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...