Console redirection (Windows)
Posted: Tue Jul 09, 2002 11:03 pm
Code updated for 5.20+
Restored from previous forum. Originally posted by PB.
PB - Registered PureBasic Coder
Edited by - PB on 10 July 2002 00:07:27
Restored from previous forum. Originally posted by PB.
Code: Select all
; Console redirection example by PB -- do whatever you want with it. :)
; This example outputs a list of files in "C:\Program Files" to a text file named "C:\Output.txt".
;
cmd$=Space(255) : GetEnvironmentVariable_("comspec",cmd$,255) ; Gets "command.com" (Win9x/ME) or "cmd.exe" (Win2K/XP).
out$="C:\Output.txt" : dir$="C:\Program Files\" ; Don't forget to include the trailing slash of the source directory!
ShellExecute_(0,"open",cmd$,"/c dir "+Chr(34)+dir$+"*.*"+Chr(34)+" > "+Chr(34)+out$+Chr(34),dir$,0)
PB - Registered PureBasic Coder
Edited by - PB on 10 July 2002 00:07:27