0

You would think this would be simple... From the command line I can execute

c:\windows\system32\cscript c:\windows\system32\iisext.vbs /ListFile

But when I try it from managed code...

Process proc = new Process();
proc.StartInfo.FileName = @"c:\windows\system32\cscript";
proc.StartInfo.Arguments = @"c:\windows\system32\iisext.vbs /ListFile";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
using (StreamReader sr = proc.StandardOutput) {
...

I get this error:

Input Error: Can not find script file "c:\windows\system32\iisext.vbs"

What am I missing?

Thanks

6
  • You're sure that file exists and you have access to it? Commented Mar 28, 2013 at 18:48
  • Can you just do one arg: "c:\windows\system32\iisext.vbs" (without the extra arg after it)? Commented Mar 28, 2013 at 18:53
  • Can you please try to run your program on "Admin mode".? Commented Mar 28, 2013 at 18:57
  • 3
    Surely it is because your program runs in 32-bit mode. Change the platform target setting to AnyCPU or use c:\windows\sysnative Commented Mar 28, 2013 at 19:09
  • TheGreatCO - Yes, tgolisch - Tried that, Awesome - Tried that Commented Apr 1, 2013 at 14:47

1 Answer 1

2

Hans is correct; the problem is almost certainly that you're running in 32bit mode, which means that C:\windows\system32 doesn't point where you think. (Verify by watching file access with Process Monitor).

Use C:\windows\sysnative instead, or compile your app to target AnyCPU.

Sign up to request clarification or add additional context in comments.

1 Comment

Is C:\windows\sysnative automatically redirecting to the right place?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.