Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: DOS box DOS app
WINDIR=DirWindows(0) COMSPEC=Environment("ComSpec") ;;Note the case, NT is like that! WM=WinMetrics(-4) switch WM case 4 WINOS=Strsub(strcat("WIN",dosversion(@major),dosversion(@minor)),1,5) break case 5 WINOS="WIN95" break case WM exit break endswitch GoSub SET_%WINOS%_CONSOLE ;Get Ready to run a DOSBOX RunShell(COMSPEC, "/c dir /p","",@NORMAL,@WAIT) ;Any Command will do ;;We're outta here EXIT :SET_WIN95_CONSOLE ;; Here's how we handle 95 consoles ;; We do a shortcutmake, but since windows knows that .lnks that point at .com files are ;; .pif files the test and the creation are to different names if !FileExist("%WINDIR%Console.PIF") ;;Just in case we've already done this if !ShortCutMake("%WINDIR%CONSOLE.LNK", "%WINDIR%COMMAND.COM", "", "%WINDIR%", @normal) then return ;;You never know if security is present endif COMSPEC=StrReplace(COMSPEC,"COMMAND.COM","CONSOLE.PIF") ;;This applies, of course only for the duration of the WB return :SET_WIN40_CONSOLE ;; Here's how we handle NT Consoles ;; Essentially we Create a Key for CMD.EXE ;; then write expanded values for it based on delta from a 640x480 screen ;; It works fairly well, but the fonts get screwy at higher resolutions ;; (this is because the Font size isn't linear, and the window size is affected by the font) ;; Notice the stand on your head approach to HEX math to avoid loading and extender. ;; By the way Don't forget to blow the key away at the end 'cause you're setting CMD.EXE here. Factor=WinMetrics(0)/640.0 WinHeight=10 ;Lines in the DOSBOX BufHeight=25 ;Lines scrollable WinWidth=80 ;width of the dosbox WinPositionX=Int(120*Factor) WinPositionY=Int(300*Factor) BaseFontX=Int(5*Factor) BaseFontY=Int(6*Factor) WinSize=(WinHeight*65536)+WinWidth BufSize=(BufHeight*65536)+WinWidth WinPos=(WinPositionY*65536)+WinPositionX FSize=(BaseFontY*65536)+BaseFontX FWeight=Int(700*Factor) CONSOLEKEY=StrCat("Console\",StrReplace(COMSPEC,"\","_")) MYKEY=RegCreateKey(@REGCURRENT, CONSOLEKEY) RegSetValue(MYKEY, "[FaceName]", "Lucida Console") RegSetDword(MYKEY,"[FontFamily]","54") RegSetDword(MYKEY,"[FontSize]",Fsize) RegSetDword(MYKEY,"[FontWeight]",Fweight) RegSetDword(MYKEY,"[HistoryNoDup]","0") ;Not quite sure what the point of this is RegSetDword(MYKEY,"[WindowPosition]",WinPos) RegSetDword(MYKEY, "[WindowSize]", WinSize) RegSetDword(MYKEY, "[ScreenBufferSize]", BufSize) returnUnder NT you need to remove the key when you're finished, otherwise you're going to get this location at every instance of a window titled c:\winnt\system32\CMD.exe.
Under 95 the .pif file will 'remember' the screen position the last time it was used, but since the pif/lnk is called CONSOLE, it will not interfere with 'normal' invocations of command.com.
Article ID: W12895
Filename: Positioning a DOS App.txt
File Created: 1999:04:15:16:50:22
Last Updated: 1999:04:15:16:50:22