I use Altar's GetDOSOutput()
(variant 1) to this question to call dos-commands by a simple delphi program. However, existing DOS program's such as DiskPart cannot be found when called by by CreateProcess whereas they present no problem when called from the DOS-prompt (Windows server 2003 X64). What could be the cause of this?
commandline: `ListVolumes.bat'
ListVolumes.bat:
path
C:\WINDOWS\SYSTEM32\DiskPart.exe /s ListVolumes.scr
dir C:\WINDOWS\SYSTEM32\DiskPart.exe
output through the program call:
I:\PartScan>path
PATH=C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\wbem;C:\Program Files (x86)\Borland\Delphi7\Bin; C:\Program Files (x86)\Borland\Delphi7\Projects\Bpl\;
I:\PartScan>C:\WINDOWS\SYSTEM32\DiskPart.exe /s ListVolumes.scr
'C:\WINDOWS\SYSTEM32\DiskPart.exe' is not recognized as an internal or external command,
operable program or batch file.
I:\PartScan>dir C:\WINDOWS\SYSTEM32\DiskPart.exe
Volume in drive C is system
Volume Serial Number is 351F-0221
Directory of C:\WINDOWS\SYSTEM32
File Not Found
output when called from the DOS prompt (note the final dir command):
PATH=C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\wbem;C:\Program Files (x86)\Borland\Delphi7\Bin; C:\Program Files (x86)\Borl
and\Delphi7\Projects\Bpl\;
I:\PartScan>C:\WINDOWS\SYSTEM32\DiskPart.exe /s ListVolumes.scr
Microsoft DiskPart version 5.2.3790.3959
Copyright (C) 1999-2001 Microsoft Corporation.
On computer: ISOETES
Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 F DVD-ROM 0 B Healthy
...
Volume 11 G DVD-ROM 0 B Healthy
I:\PartScan>dir C:\WINDOWS\SYSTEM32\DiskPart.exe
Volume in drive C is system
Volume Serial Number is 351F-0221
Directory of C:\WINDOWS\SYSTEM32
17-Feb-2007 08:17 263,680 diskpart.exe
1 File(s) 263,680 bytes
0 Dir(s) 33,111,334,912 bytes free