2

I'm trying to get my DNN module (6.1.3) to start up any kind of executable when a certain condition happens in my program. At this time I'm just trying to have it run Notepad and create a text file. Here's what I'm trying at the moment:

ProcessStartInfo pi = new ProcessStartInfo(@"C:\Windows\notepad.exe");
pi.Arguments = "> test.txt";
pi.Verb = "runas";
pi.CreateNoWindow = false;
pi.ErrorDialog = true;
pi.RedirectStandardError = true;
pi.RedirectStandardInput = true;
pi.RedirectStandardOutput = true;
pi.UseShellExecute = false;
using (Process compiler = new Process())
{
    compiler.StartInfo = pi;
    compiler.Start();
}

I've tried other methods, but nothing has worked so far. I have a suspicion that it might be a permission issue, like I need to pass in admin rights or something. I'm also unsure where it's going to attempt to create the .txt. I would think it'd be where the module is located, but again, I'm unsure. At this time I'm only running this on localhost.

Mitchell
  • 253
  • 1
  • 5
  • 16
  • 1
    It looks like you are trying to redirect standard out using `>` in the arguments, which won't work. That is a feature of cmd.exe, not a command line argument that all processes know how to handle. You'll have to read from `StandardOutput` property on the Process object. Moreover, notepad.exe is a GUI app, I don't think it is going to write anything to standard output anyway. – vcsjones Apr 14 '14 at 21:08
  • 2
    notepad doesn't write to standard out anyway. – nobody Apr 14 '14 at 21:09
  • @AndrewMedico Ha, yeah I just edited to add that. – vcsjones Apr 14 '14 at 21:10
  • That would explain why it's not working. What program would you recommend using for a test application where I can pass in arguments? Once I have that working I can use the real program, but for now I need a substitute. – Mitchell Apr 14 '14 at 21:12
  • you can pass argument to cmd.exe, new ProcessStartInfo("cmd.exe", "/c myfile.bat"); – Ehsan Apr 15 '14 at 07:24
  • The .bat I made works if I just click on the file, but trying to call it from my DNN module using cmd.exe does not. This is really starting to aggravate me. Do I need to specify the file location? – Mitchell Apr 17 '14 at 18:31

0 Answers0