Tuesday, February 25, 2014

Accessing Sysprep.exe using a program written in C#

The Sysprep folder is a read only folder in System 32. I was getting the same File not found error.


Use the LeaveDebugMode to allow System.Diagnostics.Process component of out the state that


lets you interact with OS processes that run in special mode. The below code worked for me:


System.Security.SecureString pwd = new System.Security.SecureString();

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');

pwd.AppendChar('x');


Process.LeaveDebugMode();


Process.Start("C:\\windows\\system32\\sysprep\\sysprep.exe", "<enter your user ID>", pwd, "<enter your domain>");

Process.EnterDebugMode();

No comments:

Post a Comment