HELP! getRunTime failing ONLY for "Program Files" directory!

Dear Experts,

I have a nasty security-related problem.

I just installed some anti-spyware software on my PC (Windows 2000 Pro), which failed badly.  I've since uninstalled it, rebooted, etc.  However, I still have this very specific problem:

Existing Java code (a stand-alone application, not an applet) that used to work using getRunTime no longer works FOR THE "PROGRAM FILES" DIRECTORY ONLY!

Specifically, I used to be able to do this:

    String s = "C:\\Program Files\\Microsoft Office\\Office10\\EXCEL.EXE";
    Runtime r = Runtime.getRuntime();
    try
    {
      Process p = r.exec(s);
    }
    catch (IOException ex)   { }

Now, it fails with Java.io.IOException 193, which translates to "not a valid WIN32 application".

I'm pretty sure the anti-spyware set some sort of security switch somewhere that's specific to Java (or possibly cmd.exe) and the Program Files directory.  Do you folks have any ideas on where I should look?

These are the things my testing has revealed so far:

If I rewrite the process statement to:

  Process p = Runtime.getRuntime().exec(new String[] {"cmd.exe", "/c", s});

it DOES work.  (That's not a valid solution for me, but it's certainly a BIG clue.)

I have opened up all the normal security as much as I can, and that doesn't help.  For instance, I give "Full Control" to "Everyone" for the entire "Program Files" directory, etc.

It's not the space in "Program Files".

There is nothing wrong with EXCEL.EXE itself.  I can run it directly by double-clicking on it.

The same JRE as always is being used to CALL getRunTime, and that JRE was not (directly, anyway) modified by the anti-spyware.  The JRE is NOT Microsoft's--it was downloaded direct from Sun.  However, I'm NOT certain that it's the same JRE that getRunTime ITSELF is using.  I'm vague on all that.

It's not just my code that was affected.  At least one other vendor's application had been hurt by this.  I don't know it that was Java-related.

Any help would be greatly appreciated!

Thanks,
BrianMc1958


BrianMc1958Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
>>It's not the space in "Program Files".

Are you sure? What happens with

String s = "C:/PROGRA~1/MICROS~1/Office10/EXCEL.EXE";

?
0
 
zzynxSoftware engineerCommented:
What about
>> Process p = r.exec("\"" + s + "\"");
0
 
zzynxConnect With a Mentor Software engineerCommented:
I think the reason is the space in "Program Files"
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
zzynxSoftware engineerCommented:
>> Process p = r.exec(s);
This tries to execute the program

C:\Program                                          //  which is indeed not a valid WIN32 application

with the parameter

Files\Microsoft Office\Office10\EXCEL.EXE
0
 
TimYatesConnect With a Mentor Commented:
Use:

    String s = "\"C:\\Program Files\\Microsoft Office\\Office10\\EXCEL.EXE\"";
   
0
 
zzynxSoftware engineerCommented:
Writing it like
>> Process p = Runtime.getRuntime().exec(new String[] {"cmd.exe", "/c", s});
internally puts quotes around it.
You run the cmd.exe with as parameters /c and the content of s
0
 
zzynxSoftware engineerCommented:
That's indeed what I said, Tim ;°)
0
 
TimYatesCommented:
>>  That's indeed what I said, Tim ;°)

Oh yeah...  took a bit of working out, that did ;-)  hehehe soz...
0
 
BrianMc1958Author Commented:
Dear Experts,

Thanks, but I have verified that it's not the space.  I created this directory:

C:\HAS SPACE

(pretty clever naming convention, eh?)

and copied Excel to it, and the code DID work.  So I know it's not the space.  The problem is specific to the Program Files directory itself.  

Anyway, changing my code is not a valid solution for me, as other applications have been affected, and I can't fix them by changing their code.  I need to undo whatever it was that the anti-spyware software did.

Any more ideas?  

Thanks,
--BrianMc1948
0
 
StillUnAwareConnect With a Mentor Commented:
I think You should try to install that anti-spyware sowtware again, or find the newer version. Then uninstall it without errors. This MAY help, but may not too.
0
 
BrianMc1958Author Commented:
To CEHJ:  No luck.  But NICE TRY!  I should have tried that.  You'll get at least the consolation prize here!

To StillUnAware:  That software will get re-loaded on my machine when they pry my cold dead hand from the mouse.  (It uninstalled OK.  It merely failed to run at all correctly.)

I should probably say, as an added clue, when it did run, the first thing it did was tell me that I had a directory called "Program...", and this could cause problems, and did I want to rename it!!! (I said NO).

Any more ideas?  I'm a little DESPERATE here!

Thanks,
BrianMc1958
0
 
CEHJCommented:
What happens when you try my last at the command line?

I'm also a little puzzled by

>>That's not a valid solution for me

;-)
0
 
BrianMc1958Author Commented:
To CEHJ: I get the same error message when I try your last command.  Rewriting my code is not a good solution because other applications on my machine have also been adversely affected, and I can't re-write their code.  So I really want to undo what the anti-spyware did.

Thanks again,
--BrianMc1958
0
 
CEHJCommented:
>> I get the same error message when I try your last command.

OK, and what is the output of

dir C:/PROGRA~1/MICROS~1/Office10/EXCEL.EXE

?
0
 
CEHJCommented:
Sorry - slashes the wrong way around for that ;-)
0
 
BrianMc1958Author Commented:
CEHJ--

OK.  That DOES work.  I plugged it into my program (and changed MICROS~1 to MICROS~2).  So it DOES seem to have something to do with spaces.

Yet I just re-tested my previous "spaces" example like this:

    String s = "C:\\HASABCD SPACE\\excel.exe";

I changed the test to "HASABCD" to match the number of letters in "Program" (Hey, I said I was getting desperate).  The above string still works AS IS.

So one interpretation of all this is that you can't have spaces--but only for the Program Files directory!  Is there any rationality in the universe?

Failing that, any more ideas on what might be CAUSING this behavior?

Foaming at the Mouth,
BrianMc1958
0
 
BrianMc1958Author Commented:
p.s.: I mentioned this before, but maybe I should repeat here:

If I rewrite the process statement to:

  Process p = Runtime.getRuntime().exec(new String[] {"cmd.exe", "/c", s});

it DOES work.  (That's not a valid solution for me, but it's certainly a BIG clue.)


(I don't really understand the significance of including the "cmd.exe".  I would have assumed it would default to that anyway...)

--BrianMc1958
0
 
CEHJCommented:
If you put the directory containing excel.exe on your PATH, you should be able to

Process p = Runtime.getRuntime().exec("excel.exe");
0
 
objectsConnect With a Mentor Commented:
Does this problem happen on all machines, or just the one.
If just the one then it may be related to you box and not the code.
0
 
zzynxSoftware engineerCommented:
>> I don't really understand the significance of including the "cmd.exe".  
See my previous explanation

>> So one interpretation of all this is that you can't have spaces--but only for the Program Files directory!
That would be strange, isn't it?

>> the first thing it did was tell me that I had a directory called "Program...", and this could cause problems,
>> and did I want to rename it!!! (I said NO).
You did right.
What's the quality of a program that would need one of your directories to be renamed to be able to work correctly?
btw, what was the name of that anti-spyware software?
0
 
BrianMc1958Author Commented:
To Everybody:  Well, I'm afraid I don't have any sort of full explanation for this one.  I do have a couple of work-arounds to solve the immediate problems, and it looks like I'll have to go with those now.

Thank you all for your help.

To zzynx:  The software was actually Microsoft's Anti-Spyware (Beta).  To be fair, it caused no problems on half a dozen other machines here.
0
 
zzynxSoftware engineerCommented:
Just to check that the space you see in your "Program Files" directory really IS a space:
can you go to it in a DOS session by typing:
C:\>cd "Program Files"

It sounds ridiculous, but I know of malpractices to replace the space by another ASCII character the does look like a space
Just to be sure
0
 
zzynxSoftware engineerCommented:
Thanks
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.