Je voudrais savoir comment exécuter un fichier batch dans QBasic.Comment exécuter un fichier batch dans QBasic?
Et quand je veux dire dans je veux dire PAS dans une nouvelle fenêtre.
Pouvez-vous m'aider?
Je fais un faux DOS.
Je voudrais savoir comment exécuter un fichier batch dans QBasic.Comment exécuter un fichier batch dans QBasic?
Et quand je veux dire dans je veux dire PAS dans une nouvelle fenêtre.
Pouvez-vous m'aider?
Je fais un faux DOS.
Je ne trouve pas le moyen d'exécuter des commandes DOS dans la même fenêtre. Ce que vous pouvez faire est SHELL _HIDE "[commande]> outputfile.txt", puis ouvrez ce fichier et imprimez chaque ligne à votre application qb.
L'exemple est pas parfait, mais peut être utilisé comme base pour y aller:
RunCommand "dir"
END
SUB RunCommand (enteredCommand$)
IF LEN(enteredCommand$) = 0 THEN EXIT FUNCTION 'no entry
IF LEN(ENVIRON$("OS")) THEN CMD$ = "CMD /C " ELSE CMD$ = "COMMAND /C "
SHELL _HIDE CMD$ + enteredCommand$ + " > output"
OPEN "output" FOR APPEND AS #1 'this may create the file
L% = LOF(1) 'verify that file and data exist
CLOSE #1
IF L% THEN 'read file if it has data
OPEN "output" FOR INPUT AS #1
WHILE NOT EOF(1)
LINE INPUT #1, line$ 'read only line in file
PRINT line$
WEND
CLOSE #1
ELSE
PRINT "Command Not Found" 'returns zero length string if path not found
END IF
KILL "output" 'deleting the file is optional
END FUNCTION
Votre réponse serait plus utile si vous pouvez décider si les guillemets sont obligatoires ou non - ou expliquer quand ils sont requis. – Blackwood
Pour autant que je me souviens qu'il devrait y avoir une commande 'shell' dans QBasic ... – aschipfl