Hallo Leute, irgendwie scheint der Code unter Studio 2017 nicht mehr zu Funktionieren. Hoffe mir kann wer helfen.

Grüße

Chris


Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RunAsAdmin
{
    public partial class Form1 : Form
    {
        private void Form1_Load(object sender, EventArgs e)
        {
            FileInfo fi = new FileInfo(Assembly.GetEntryAssembly().Location);
            string path0 = @"C:\\snapshot_1.42\\snapshot_1.42.exe";//Auszuführende Datei anpassen
            ProcessStartInfo myProcess = new ProcessStartInfo(path0);
            myProcess.Domain = "XXX.XXX"; //"Domain"
            myProcess.UserName = "Administrator"; //Adminaccount
            string password = "P@sswort"; //"Passwort"
            SecureString sec_pass = new SecureString();
            Array.ForEach(password.ToArray(), sec_pass.AppendChar);
            sec_pass.MakeReadOnly();
            myProcess.Password = sec_pass;
            myProcess.UseShellExecute = false;
            Process.Start(myProcess);
            Application.Exit();
        }
    }