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


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

Posted on 2009-05-01
Medium Priority
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
  • 2
  • 2
LVL 12

Assisted Solution

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

Author Comment

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

Assisted Solution

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

Accepted Solution

JayWallace1979 earned 0 total points
ID: 24295900

I think this is whats going on

Thanks for everyones help

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