Recently i had to create an automation tool which entailed the checking of registry entries using dot net …
one stage of the automation required me to check for the presence of a particular entry in the registry ,and if not then carry on with the installation of the particular setup file …
i came across this particular link http://www.dotnetspider.com/kb/ShowArticle.aspx?ArticleId=1406 which i used extensively to carry out the checkin of registry part .
public string Gettest()
{
string ds = null;
RegistryKey key = Registry.LocalMachine.OpenSubKey(“SOFTWARE\\Microsoft\\.NETFramework\\v3.0″);
if (key != null)
{
ds = “the entry exists in registry”;
flag = 0;
}
else
{
return (RunExe(“c:\\code\\DotnetFramework\\dotnetfx3setup.exe”, “dot net framework 3 install”));
}
return ds;
}
the above snippet is slightly modified version of a fuction in the mentioned link …..
also after checking the registry for the framework it also runs a setup file if it is not present …
the runexe function essentially implements the following statements
System.Diagnostics.Process.Start(path);
System.Windows.Forms.Application.DoEvents();
where path contains the path of the setup file ( in this case dotnetfx3setup)
the system.diagnostics.process.start can be used to run exe s or batch files …


