Use shell to run cmd dir in windows xp
Posted: Wed Jan 14, 2009 2:34 pm
I am having a problem using the shell function to run a windows command - I want to run the dir command and send the output to a text file for further processing. I can get shell to display the calculator as an example but I cannot get it to produce a command prompt window and hence run the dir command.
I can fire up the Windows calculator using this code:
Shell("c:\windows\system32\calc.exe",2)
But this almost identical code does NOT bring up a Command Prompt window:
Shell("C:\WINDOWS\system32\cmd.exe",2)
In each case, the code between the quotes does work fine when entered in Start, Run
Please does anyone have any idea what is going on here?
(As background, what I am trying to execute is something like this, but without success:
Shell("C:\WINDOWS\system32\cmd.exe",2,"dir I:\Backups\Backup*.odt > C:\tempdirtext.txt",true)
which I hope will send the output from the dir command to a temporary text file for further processing.
But I am stuck on the very first step.)
OS is Windows XP Media Edition,, OOo v3.0.0
I can fire up the Windows calculator using this code:
Shell("c:\windows\system32\calc.exe",2)
But this almost identical code does NOT bring up a Command Prompt window:
Shell("C:\WINDOWS\system32\cmd.exe",2)
In each case, the code between the quotes does work fine when entered in Start, Run
Please does anyone have any idea what is going on here?
(As background, what I am trying to execute is something like this, but without success:
Shell("C:\WINDOWS\system32\cmd.exe",2,"dir I:\Backups\Backup*.odt > C:\tempdirtext.txt",true)
which I hope will send the output from the dir command to a temporary text file for further processing.
But I am stuck on the very first step.)
OS is Windows XP Media Edition,, OOo v3.0.0