Instead of trying to write out a batch script to a cmd process, use Directory.GetFiles("c:\\somepath\\", "*.dll;*.ocx")
to get the files you want to register - then use process.start
to start regsvr32
processes (with the /silent
argument) and check the return code to know if you were successful or not.
If you try and do it in the script, you'll only get the return code of the cmd process, not of the regsvr32 processes which is what you're interested in.