Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. 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)""";
  2.  
  3. Process.Start("cmd.exe", grantAccess);
  4.  
  5. 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)""";
  6.  
  7. Process processGrant = new Process();
  8. ProcessStartInfo startInfoGrant = new ProcessStartInfo();
  9. startInfoGrant.Domain = "domain";
  10. startInfoGrant.UserName = "user1";
  11. startInfoGrant.Password = userPassword; // this is a SecureString
  12. startInfoGrant.FileName = "cmd.exe";
  13. startInfoGrant.Verb = "runas"; // I've tried it with or without this line
  14. startInfoGrant.Arguments = grantAccess;
  15. startInfoGrant.CreateNoWindow = true;
  16. startInfoGrant.UseShellExecute = false;
  17. processGrant.StartInfo = startInfoGrant;
  18. processGrant.Start();
  19. processGrant.WaitForExit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement