PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Executing a Dos-Command from within a Windev Application (WD8)
Executing a Dos-Command from within a Windev Application (WD8)
Débuté par lieven.de.nys, 27 sep. 2004 11:26 - 4 réponses
Posté le 27 septembre 2004 - 11:26
I have to execute DOS-commands from within a Windev-program.
This works (fine) since a longer while using an earlier filled-in
(MS-)Batch-file and then asking Windev to execute that Batch-file
via the statement ExeRun.
Ex: ExeRun("My_BatchFile.bat",,exeActif,exeBloquant)
Within the My_Batch-file.bat there is most of the time just one command:
copy c:\labels\out.asc LPT1:
Sometimes a few more lines like (when printing to a Serial-printer):
mode com2: 9600,n,8,1
mode lpt1=com2
copy c:\vblabels\out.asc LPT1:
As said before, this solution via the Batch-file "works fine",
but is a bit ugly, as, each time, it executes,
it shows for a split-second the "black" MS-Dos-screen.
I tried several ways already to write a "straight" ExeRun-statement like:
lbPrintRes = ExeRun(lsDOSCmmnds + "copy c:\vblabels\out.asc LPT1:",...
exeActif,exeBloquant)
Where lsDOSCmmnds = "C:\WINNT\SYSTEM32\cmd.exe "
But lbPrintRes always returns False!
For the Serial example I manage to execute the "mode"-commands
(still with a black-screen,) stating:
lbPrintRes = ExeRun(WinNTSysMap+"mode.com com1: 9600,n,8,1" ,...
exeActif,exeBloquant)
lbPrintRes = ExeRun(WinNTSysMap+"mode.com lpt1=com1" ,...
exeActif,exeBloquant)
Where WinNTSysMap = "C:\WINNT\SYSTEM32"
But then again I cannot send the following "copy"-command
from within Windev via an ExeRun(...)
Anybody knowa more about this?
Thanks foor Your attention, help.
Lieven De Nys.
Member of the Benelux (Dutch speaking) Windev-Developpersgroup.
Posté le 23 septembre 2004 - 19:49
Hello Lieven,
your Mode.com settings are only valid in the command box, after returning they are lost.
Just cursios, why not use WinDev's sOpen/sWrite etc, command?
Best regards
Raimund

I have to execute DOS-commands from within a Windev-program.
This works (fine) since a longer while using an earlier filled-in
(MS-)Batch-file and then asking Windev to execute that Batch-file
via the statement ExeRun.
Ex: ExeRun("My_BatchFile.bat",,exeActif,exeBloquant)
Within the My_Batch-file.bat there is most of the time just one command:
copy c:\labels\out.asc LPT1:
Sometimes a few more lines like (when printing to a Serial-printer):
mode com2: 9600,n,8,1
mode lpt1=com2
copy c:\vblabels\out.asc LPT1:
As said before, this solution via the Batch-file "works fine",
but is a bit ugly, as, each time, it executes,
it shows for a split-second the "black" MS-Dos-screen.
I tried several ways already to write a "straight" ExeRun-statement like:
lbPrintRes = ExeRun(lsDOSCmmnds + "copy c:\vblabels\out.asc LPT1:",...
exeActif,exeBloquant)
Where lsDOSCmmnds = "C:\WINNT\SYSTEM32\cmd.exe "
But lbPrintRes always returns False!
For the Serial example I manage to execute the "mode"-commands
(still with a black-screen,) stating:
lbPrintRes = ExeRun(WinNTSysMap+"mode.com com1: 9600,n,8,1" ,...
exeActif,exeBloquant)
lbPrintRes = ExeRun(WinNTSysMap+"mode.com lpt1=com1" ,...
exeActif,exeBloquant)
Where WinNTSysMap = "C:\WINNT\SYSTEM32"
But then again I cannot send the following "copy"-command
from within Windev via an ExeRun(...)
Anybody knowa more about this?
Thanks foor Your attention, help.
Lieven De Nys.
Member of the Benelux (Dutch speaking) Windev-Developpersgroup.



http://www.invitec.com
Posté le 30 septembre 2004 - 23:42
Hello Lieven,

For a long time we used Kyocera printers.
Kyocera had Prescribe commando's to select fonts etc etc

for example:

!R! map 10,10; (moves to cursor)
!R! font 15;
!R! say Have a nice day

I wrote all the commands to a file with fwrite etc and then simply copy the file to lpt1 or to the printerqueue.

Something like: fcopy(file,lpt1) or fcopy(File,Queuename)


See you in Meer.
Posté le 08 juillet 2025 - 21:16
// 1. Define safe temp file path
sTempFile is string = fTempPath() + "cmd_output.txt" // Always writeable

// 2. Build the CMD command with the file path in quotes!
sCommand is string = "cmd /C ipconfig > """ + sTempFile + """"

// 3. Execute the command
ExeRun(sCommand, exeActive, exeWait)

// 4. Wait a little for the OS to flush output
Wait(100)

// 5. Load and show result
IF fFileExist(sTempFile) THEN
sResult is string = fLoadText(sTempFile, foUnicode)
Info("Resultado:", sResult)
fDelete(sTempFile)
ELSE
Error("Error with the Tempfile: " + sTempFile)
END
Posté le 08 juillet 2025 - 21:17
a écrit :
I have to execute DOS-commands from within a Windev-program.
This works (fine) since a longer while using an earlier filled-in
(MS-)Batch-file and then asking Windev to execute that Batch-file
via the statement ExeRun.
Ex: ExeRun("My_BatchFile.bat",,exeActif,exeBloquant)
Within the My_Batch-file.bat there is most of the time just one command:
copy c:\labels\out.asc LPT1:
Sometimes a few more lines like (when printing to a Serial-printer):
mode com2: 9600,n,8,1
mode lpt1=com2
copy c:\vblabels\out.asc LPT1:
As said before, this solution via the Batch-file "works fine",
but is a bit ugly, as, each time, it executes,
it shows for a split-second the "black" MS-Dos-screen.
I tried several ways already to write a "straight" ExeRun-statement like:
lbPrintRes = ExeRun(lsDOSCmmnds + "copy c:\vblabels\out.asc LPT1:",...
exeActif,exeBloquant)
Where lsDOSCmmnds = "C:\WINNT\SYSTEM32\cmd.exe "
But lbPrintRes always returns False!
For the Serial example I manage to execute the "mode"-commands
(still with a black-screen,) stating:
lbPrintRes = ExeRun(WinNTSysMap+"mode.com com1: 9600,n,8,1" ,...
exeActif,exeBloquant)
lbPrintRes = ExeRun(WinNTSysMap+"mode.com lpt1=com1" ,...
exeActif,exeBloquant)
Where WinNTSysMap = "C:\WINNT\SYSTEM32"
But then again I cannot send the following "copy"-command
from within Windev via an ExeRun(...)
Anybody knowa more about this?
Thanks foor Your attention, help.
Lieven De Nys.
Member of the Benelux (Dutch speaking) Windev-Developpersgroup.


// 1. Define safe temp file path
sTempFile is string = fTempPath() + "cmd_output.txt" // Always writeable

// 2. Build the CMD command with the file path in quotes!
sCommand is string = "cmd /C ipconfig > """ + sTempFile + """"

// 3. Execute the command
ExeRun(sCommand, exeActive, exeWait)

// 4. Wait a little for the OS to flush output
Wait(100)

// 5. Load and show result
IF fFileExist(sTempFile) THEN
sResult is string = fLoadText(sTempFile, foUnicode)
Info("Resultado:", sResult)
fDelete(sTempFile)
ELSE
Error("No se pudo generar el archivo: " + sTempFile)
END