Question

I am developing a Windows Form Application which will have one option as "Export a Site" and another to "Import a Site" I want it to be done using following STSADM commands but not sure what I need to add in button click event (C#) so that it will execute a STSADM command.

stsadm.exe -o export -url https://abc20.dev.com/cl/asdjsa/default.aspx -filename C:\Export.cab -includeusersecurity -versions 4 –overwrite

Edit this worked for me

Process exportSite = new Process();

string commonFilesPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonProgramFiles);
string commandLine = " -o export -url " + SPContext.Current.Web.Url + " -filename c:\\" + tempName + ".exp -overwrite -includeusersecurity";

exportSite.StartInfo.UseShellExecute = true;
exportSite.StartInfo.FileName = commonFilesPath + @"\Microsoft Shared\web server extensions\12\BIN\" + "stsadm.exe ";
exportSite.StartInfo.Arguments = commandLine;
exportSite.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
exportSite.Start();
exportSite.Close();
Was it helpful?

Solution

I'm pretty sure System.Diagnostics.Process.Start() would let you run STSADM from .NET code.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top