Register or unregister multiple dll files using .net

Generally we require scheduled application. Our object is to register multiple dll files without information messagebox using .NET. This is great for automated app.

Assume path1,path2 and path3 are complete path of dll files including name.


System.Diagnostics.Process Prcs;
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path1 + @""" /s");
Prcs.WaitForExit();
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path2 + @""" /s");
Prcs.WaitForExit();
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path3 + @""" /s");
Prcs.WaitForExit();
Prcs.Close();

To Unregister:

System.Diagnostics.Process Prcs;
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path1 + @""" /s /u");
Prcs.WaitForExit();
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path2 + @""" /s /u");
Prcs.WaitForExit();
Prcs = System.Diagnostics.Process.Start("regsvr32.exe", "\"" + path3 + @""" /s /u");
Prcs.WaitForExit();
Prcs.Close();

1 comment:

  1. ok, but you might want and try this cmd..

    (works from command line too)

    For %i in (*.foo) do regsvr32 %i

    (replace *.foo with *.dll or *.ocx) also can add /u and /s as needed.

    Sean Rohde

    ReplyDelete