turn123
asked on
Process.Start "Access is denied" exception
When I run this code it will start the cmd process twice then the third time it gives an unhandled exception "Access is denied". What is going on and how do I fix it?
string pram = "";
for (int i = 0; i < 4000; ++i)
{
pram += 'i';
if(pram.Length > 2050)
Process.Start("cmd.exe", pram);
}
CMD has a maxium size for a "command line" at about 8k... What are you trying to do?
ASKER
I'm passing an XML file to another program as a command line argument to be parsed and printed.
Basically I'm trying to get the same functionality as an existing Perl script that calls it with the system command.
Is there another way I should be doing this?
Basically I'm trying to get the same functionality as an existing Perl script that calls it with the system command.
Is there another way I should be doing this?
system "PrintInvoiceVer.exe $xml";
Pardon me, but what the heck does that have to do with the sample you posted.... I'm very confused.
Try this: "cmd /c PrintInvoiceVer.exe " & xmlfilenamevariable
Try this: "cmd /c PrintInvoiceVer.exe " & xmlfilenamevariable
ASKER
The example I posted was an a test case showing where the problem was occurring. The second example is was what the current program I am replacing is doing that works. It seems that both should work.
Anyway when I try your suggestion I'm getting a compile error.
"Operator '&' cannot be applied to operands of type 'string' and 'string'"
Anyway when I try your suggestion I'm getting a compile error.
"Operator '&' cannot be applied to operands of type 'string' and 'string'"
Ooops, try "+"
ASKER
Now it is throwing an unhandled exception "The system cannot find the file specified"
string pram = "";
for (int i = 0; i < 4000; ++i)
{
pram += 'i';
if (pram.Length > 2050)
Process.Start("cmd /c PrintInvoiceVer.exe " + pram);
}
Because there is no file called iiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiii iiiiiiiiii ii
Again, that's a very strange example. I don't understand what that example has to do with anything... are you testing the length of the items you can put in a command line?
Again, that's a very strange example. I don't understand what that example has to do with anything... are you testing the length of the items you can put in a command line?
ASKER
There is no file called
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<InvoiceQueryRs statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<InvoiceRet>
<TxnID>39C6BB-1220637230</ TxnID>
<TimeCreated>2008-09-05T13 :53:50-05: 00</TimeCr eated>
either. This is part of the parameter I'm trying to pass to a command line program so that it can process it. It doesn't seem to matter what I pass. Once it exceeds a certain length I get the access is denied error when using process.start.
When I try using the example you gave it says it can't find the file.
<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<InvoiceQueryRs statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<InvoiceRet>
<TxnID>39C6BB-1220637230</
<TimeCreated>2008-09-05T13
either. This is part of the parameter I'm trying to pass to a command line program so that it can process it. It doesn't seem to matter what I pass. Once it exceeds a certain length I get the access is denied error when using process.start.
When I try using the example you gave it says it can't find the file.
Wow.... Now, I know I'm totally lost.
Let's start from the very beginning and have you describe what the heck you're trying to do. Please don't give us an example of what you've tried so far... that's obvioulsy not helping much. Instead concentrate on a bettter description of the problem
Let's start from the very beginning and have you describe what the heck you're trying to do. Please don't give us an example of what you've tried so far... that's obvioulsy not helping much. Instead concentrate on a bettter description of the problem
ASKER
Ok I have a program that excepts a command line argument of an XML file. I am trying to start this program and pass it the XML file as an argument.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dang.... I missed a word
The name of the file should NOT make the command line too long.... it'd be something like this:
The name of the file should NOT make the command line too long.... it'd be something like this:
ASKER
That's basically what I'm doing now. I would prefer not to have to write a file if that is possible to do. I'm thinking there should be a way to do it without writing a file as I can do it in Perl without having to write a file.
ASKER