I need to launch a command from the prompt with parameters within my WPF C# application to synchronize two databases.
The command in the file.bat is as follows:
"c:\Program Files\Microsoft SQL Server\100\COM\replmerg.exe" -Publisher [sql2008-srv\sql2008srv] -PublisherDB [MIODB] -Publication [DBPublication] -Subscriber [UTENTE\SQL2008R2EXP] -SubscriberDB [MIODB] -SubscriptionType 1 -SubscriberSecurityMode 1 -Distributor [sql2008-srv\sql2008srv] -OutputVerboseLevel 4 -Output C:\Windows\Temp\mergeagent.log
Below my code but does not run. Just open the shell with the flashing cursor:
string ciao = "\"c:\\Program Files\\Microsoft SQL Server\\100\\COM\\replmerg.exe\" -Publisher [sql2008-srv\\sql2008srv] -PublisherDB [DataNavi] -Publication [DataNaviPublication] -Subscriber [SFRANCESCO\\SQL2008R2EXP] -SubscriberDB [DataNavi] -SubscriptionType 1 -SubscriberSecurityMode 1 -Distributor [sql2008-srv\\sql2008srv] -OutputVerboseLevel 4 -Output C:\\Windows\\Temp\\mergeagent.log ";
try
{
Process.Start("CMD.exe", "/K" +ciao);
}
catch (Exception ex)
{
// Implement appropriate error handling here.
MessageBox.Show("errore:" + ex.Message, "Errore sincronizzazione");
}