0

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();
  • I know this is not what you asked for, but you should rather use powershell. STSADM is dying very quickly. Also, why not just use the Microsoft.SharePoint.dll directly in your winforms app? Make sure you set your compiler to compile it as 64 bit though. – Fox Aug 3 '12 at 13:05
  • Thanks dude... it got worked for me in console application, can you please tell me how to import it based on this export file. – user12904 Nov 8 '12 at 13:42
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.