Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string grantAccess = @"runas /savecred /user:domainuser1 ""icacls \ext.kfgdfsGroupFTPData_Exchange" + login + @" /grant: GFKD-RE-AP-RT-GIM-USER:(OI)(CI)(RC,RD,WD,AD,REA,WEA,X,DC,RA,WA)""";
- Process.Start("cmd.exe", grantAccess);
- string grantAccess = @"/savecred ""icacls \ext.gfkdfsGroupFTPData_Exchange" + login + @" /grant: GFKD-RE-AP-RT-GIM-USER:(OI)(CI)(RC,RD,WD,AD,REA,WEA,X,DC,RA,WA)""";
- Process processGrant = new Process();
- ProcessStartInfo startInfoGrant = new ProcessStartInfo();
- startInfoGrant.Domain = "domain";
- startInfoGrant.UserName = "user1";
- startInfoGrant.Password = userPassword; // this is a SecureString
- startInfoGrant.FileName = "cmd.exe";
- startInfoGrant.Verb = "runas"; // I've tried it with or without this line
- startInfoGrant.Arguments = grantAccess;
- startInfoGrant.CreateNoWindow = true;
- startInfoGrant.UseShellExecute = false;
- processGrant.StartInfo = startInfoGrant;
- processGrant.Start();
- processGrant.WaitForExit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement