[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Trouble with invoking cscript.exe  on remote machine via .NET webservice

Posted on 2009-05-01
4
Medium Priority
?
1,216 Views
Last Modified: 2013-12-17
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?


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;
            
        }
    }
}

Open in new window

0
Comment
Question by:JayWallace1979
  • 2
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:williamcampbell
williamcampbell earned 200 total points
ID: 24281770
Can you Physically go tot he remote machine and try to run the script locally by hand?

It would be interesting to know if it runs. If it doesnt then we can ruke out the problem as Web Service related
0
 

Author Comment

by:JayWallace1979
ID: 24281797
Yes I can run the process locally with the same arguments and It runs fine
0
 
LVL 12

Assisted Solution

by:williamcampbell
williamcampbell earned 200 total points
ID: 24282252
"This error message means that the user concerned doesn't have read access to some system file required by the application. "

May be a security issue. Try running it as administrator. Try removing the MakePasswordSecure function.

Link about the error
http://www.tech-pro.net/howto_015.html
0
 

Accepted Solution

by:
JayWallace1979 earned 0 total points
ID: 24295900
http://support.microsoft.com/kb/950312

I think this is whats going on


Thanks for everyones help
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month18 days, 11 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question