Running a CMD command from ASP.NET page

mcdonnc2004
07-06-2006, 07:31 AM
Hey all,

I have a Base64 string that I need to run through a Java appet to generate a JPEG. If I open cmd I would type in the following:

java -cp mxsigviewer.jar com.momote.signatureviewer.SignatureViewerConsole -d . -o test -b64 wz8LDzIhOTBASVBJWkBAMTAgACgSIiIyEiISs8PBqbC5qQA+KQBCJgoKKSKSoqsqMZIAUC kKKwoaGyobKxsqOSk5OiEwAsGhwqCyoTFBIDIjBaPDobKhsKmwqgB5C5KSk6OUkqKiogKk kqMwKis7SipLSjApIrmi0sKyopICIDEpOjk5OxoKC6ChoACFGQoCMDAgMCmgoqKzoZOSIj ApKTobOxoqk5KSk5KTo5OzorGxsKCpuaAAlxoKICAgMCApsKKgkqIDIiApKhoKGwoSA5OS lAOUA7Ojs7GgoaHBoACdMiocORorKysrGksrKiqpobGzopMTITAgIxOjk6KyoaIA

And that would produce a JPEG called test.jpg but I cannot get this work from an ASP.NET page. I tried System.Diagnostics.Process.Start on cmd.exe and passed the above as an argument but its seems it doesn't run.

The Base64 string comes to the page as a http parameter (which I have called sig). I'd like to be able to pass cmd something like:

System.Diagnostics.Process.Start("cmd.exe java -cp mxsigviewer.jar com.momote.signatureviewer.SignatureViewerConsole -d . -o test -b64 " & sig)

But that does not work! Can anyone help me with this?

wayneph
07-06-2006, 07:44 AM
The ASPNET and Anonymous User accounts are not going to have any permissions outside of IIS and your defined Web Folders. My guess is that you're going to have to give execute permissions on the directory where java is located, permissions where your .jar file is located, and permissions where you'll be writing the file to. Since I'm not familiar with Java behind the scenes, I'm not 100% sure what permissions those are.

Also, you may want to look at started java directly with the command line you specified. You shouldn't need to call cmd.exe first. Just put 'java' in as the process to be started, and the rest of the command as the options. (or arguments, i can't remember of the top of my head what the property is called.)

mcdonnc2004
07-06-2006, 03:55 PM
I tried putting in the full path to the java.exe executable but I kept getting file not found which made me think I was not getting access. I gave the ASPNET account access to the Java folder but still got the same thing.

One thing I didn't try was giving ASPNET access to the Program Files folder which the Java folder is located in. The .jar file and the .jpg to be written will be going in the root of the website so that should be ok.

wayneph
07-07-2006, 07:01 AM
then you may need to specify full paths to things directly in the command line. You may also want to specify the WorkingDirectory using the ProcessStartInfo class for starting your process.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum