On 27 Dec. 2007, 22:02, "Dave R." <dwragle (at) drbsystems (dot) com>
wrote:
> "Joe" <j...@[EMAIL PROTECTED]
> wrote in message
>
> news:13mod69bok30h86@[EMAIL PROTECTED]
>
>
>
>
>
> > Dave R. wrote:
> >> "Joe" <j...@[EMAIL PROTECTED]
> wrote in message
> >>news:13mnjamps7fpn19@[EMAIL PROTECTED]
> >>> I keep tring to shell out of my program to run a small utility
> >>> program. I use Exec. and I keep getting the same error, Unknown
> >>> Identifier. That I don't under stand. That command or option in
> >>> listed in the help files.
>
> >>> Exec ('CMD.EXE /C ' + myutil.exe);
>
> >> The declaration for Exec is:
>
> >> procedure Exec(Path, CmdLine: string);
>
> >> So the compiler is treating myutil.exe as a variable name /
> >> identifier, but since it hasn't been declared as one the compiler
> >> throws an error. You probably need something like:
>
> >> Exec(GetEnv('COMSPEC'), '/C myutil.exe);
>
> >> GetEnv('COMSPEC') will return the full path to the command
> >> interpreter, and the '/C myutil.exe' will complete the command line
> >> you need.
>
The problem is caused by Windows XP: You dont get the correct
environment using GetEnv().
First test:
Exec('C:\WINDOWS\SYSTEM32\CMD.EXE', '/C C:\TURBO7\MyUtil.EXE');
and remember to include $M-directive.
When you see it runs like a charm you can modify the the Exec-
statement using paramaters instead of fixed strings.
Keep us posted.
Svend Broholm


|