Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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();
share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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