QB64 Phoenix Edition
Program Solution#2 - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Program Solution#2 (/showthread.php?tid=3750)



Program Solution#2 - eoredson - 06-16-2025

Solves specifying Shell w/o parameter:

Code: (Select All)
Print "Enter DOS command";
Input Var$
Call ShellProgram(Var$)
End

' SHELL Param$
Sub ShellProgram (Var$)
  If Len(Var$) Then
      FX$ = "SHELL.BAT"
      X = FreeFile
      Open FX$ For Output As #X
      Print #X, "@ECHO OFF"
      Print #X, Var$
      Print #X, "PAUSE"
      Print #X, "EXIT"
      Close #X
      Shell FX$
      Print "Returned from DOS shell."
      Exit Sub
  End If
  Print "Type 'EXIT' to return."
  Comspec$ = Environ$("COMSPEC")
  If Len(Comspec$) Then
      Shell Comspec$
  Else
      Shell "CMD"
  End If
  Print "Returned from DOS shell."
End Sub