JayWallace1979
asked on
Trouble with invoking cscript.exe on remote machine via .NET webservice
I am trying to invoke cscript.exe on a remote server to run a vbScript used to deploy content via a CMS system. running cscript in the remote machine directly executes the script as expected but when I try to invoke cscript via my web services I get an error of
"------------------------- --
cscript.exe - Application Error
-------------------------- -
The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.
-------------------------- -
OK
-------------------------- -
"
I have attached the code to my webservice. Am I setting up the Process incorrectly?
"-------------------------
cscript.exe - Application Error
--------------------------
The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.
--------------------------
OK
--------------------------
"
I have attached the code to my webservice. Am I setting up the Process incorrectly?
namespace TestDeployService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://hqauth1vm/KitchenTestCMS/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class TestKitchenService : WebService
{
public TestKitchenService()
{
}
System.Diagnostics.Process testDeployProcess;
public string ErrorText { get; set; }
[WebMethod]
public int Deploy()
{
// WindowsImpersonationContext impersonationContext = ((WindowsIdentity)User.Identity).Impersonate();
InitializeComponent();
testDeployProcess.Start();
testDeployProcess.WaitForExit();
//impersonationContext.Undo();
return testDeployProcess.ExitCode;
}
private void InitializeComponent()
{
testDeployProcess = new System.Diagnostics.Process();
//
// testDeployProcess
//
testDeployProcess.EnableRaisingEvents = true;
testDeployProcess.StartInfo.Arguments = "\"\\hqauth1Vm\\d$\\Program Files\\CmsDeploymentTool\\deploykitchen.vbs\"";
testDeployProcess.StartInfo.Domain = "HQAUTH1VM";
testDeployProcess.StartInfo.ErrorDialog = true;
testDeployProcess.StartInfo.FileName = "cscript";
testDeployProcess.StartInfo.LoadUserProfile = false;
testDeployProcess.StartInfo.Password = MakePasswordSecureString("sW&nUyUcr5!wezu");
testDeployProcess.StartInfo.RedirectStandardError = true;
testDeployProcess.StartInfo.RedirectStandardInput = true;
testDeployProcess.StartInfo.RedirectStandardOutput = true;
testDeployProcess.StartInfo.StandardErrorEncoding = null;
testDeployProcess.StartInfo.StandardOutputEncoding = null;
testDeployProcess.StartInfo.UserName = "cmsLocalAdmin";
testDeployProcess.StartInfo.UseShellExecute = false;
testDeployProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
testDeployProcess.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(this.testDeployProcess_ErrorDataReceived);
testDeployProcess.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(this.testDeployProcess_OutputDataReceived);
}
void testDeployProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
ErrorText = e.Data;
}
private void testDeployProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
ErrorText = e.Data;
}
public SecureString MakePasswordSecureString(string pwd)
{
string pwdText = pwd;
SecureString secPwd = new SecureString();
secPwd.Clear();
for (int i = 0; i < pwdText.Length; i++)
{
secPwd.AppendChar(pwdText[i]);
}
return secPwd;
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER