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

Posted on 2009-05-01
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.

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)]


    public class TestKitchenService : WebService


        public TestKitchenService()



System.Diagnostics.Process testDeployProcess;

        public string ErrorText { get; set; }


        public int Deploy()


              //  WindowsImpersonationContext impersonationContext = ((WindowsIdentity)User.Identity).Impersonate();        





            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();


            for (int i = 0; i < pwdText.Length; i++)




            return secPwd;





Open in new window

Question by:JayWallace1979
    LVL 12

    Assisted Solution

    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

    Author Comment

    Yes I can run the process locally with the same arguments and It runs fine
    LVL 12

    Assisted Solution

    "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

    Accepted Solution


    I think this is whats going on

    Thanks for everyones help

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now