I am trying to write a program to browse to a WSP file and then run the STSADM to make it easier to add solutions to our sharepoint site. The STSADMN is located in c:\program files\common files\microsoft shared\web server extensions\14\bin\stsadmn.exe.
stsadm -o addsolution -filename "filename that was selected"
This currently has to run in powershell.
After that completes I need it to run this:
stsadm -o deploysolution -name "selected WSP" -allowgacdeployment -immediate
I am just not sure how to call powershell and then run this command. and of course a messagebox.show "Completed". All I have right now is a form that browses to a WSP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "Open WSP File";
fDialog.Filter = "WSP Files|*.wsp";
fDialog.InitialDirectory = @"C:\";
if(fDialog.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(fDialog.FileName.ToString());
}
}
}
}
I got this far as figuring out that I need system.Diagnostics reference.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace callprogram
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "powershell.exe";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();
return;
}
}
}
Powershell actually not executes but of course I need to run the commands in the push of a button. I am new to C# and still learning.