views:

9

answers:

1

I'm trying to run a Jscript task from a C# console application.

The Jscipt file is not mine so I can't change it. The script moves some files and this is what is causing the issues.

When I run the script manually, i.e. form the shell it executes correctly. When I try and run the script from my console application the bulk of the process runs but I get a ":Error = Permission denied" error when it tries to move the files.

I've tried every permutation of the Diagnostics.Process class that I can think of but I've had no luck.

My current code:

Process process = new Process();

process.StartInfo.WorkingDirectory = Path.GetDirectoryName((string)path);
process.StartInfo.FileName = @"cmd.exe";
process.StartInfo.Arguments = "/C " + (string)path;

process.StartInfo.UseShellExecute = false;
process.StartInfo.Verb = "runas";

process.StartInfo.LoadUserProfile = true;

process.StartInfo.Domain = "admin";
process.StartInfo.UserName = @"cardax_sync_test";
process.StartInfo.Password = GetSecureString("abc123");

process.Start();

process.WaitForExit();

Any ideas?

Thanx

A: 

Rookie Mistake!

I forgot to close the text reader that creates one of the input files for the jscript.

I'll submit this question for deletion when it get's old enough. Don't want more useless info clogging up the net!

Stephen Reid