Difference between revisions of "Shortcuts that You Run in DOSBox"

From DOSBoxWiki
Jump to: navigation, search
(added edit checking)
m (A Small Shortcut Maker: highlighted important parts of code)
Line 25: Line 25:
 
* Unfortunately this can't be run from dosbox due to the set /P command not being supported by DOS 6.22 (if there is a native command that will allow for the input of a string then feel free to modify the code you will also have to change the choice syntax from choice [/m "text"] to choice [text])
 
* Unfortunately this can't be run from dosbox due to the set /P command not being supported by DOS 6.22 (if there is a native command that will allow for the input of a string then feel free to modify the code you will also have to change the choice syntax from choice [/m "text"] to choice [text])
 
* Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and write this to it
 
* Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and write this to it
 +
* The important parts of the code are in '''bold'''
 
** ''@echo off''
 
** ''@echo off''
: ''set /P file="Enter the name of the program: "''
+
: '''''set /P file="Enter the name of the program: "'''''
 
: ''choice /m "Does the program folder have the same name as the program file (only if folder is in shortcut directory): "
 
: ''choice /m "Does the program folder have the same name as the program file (only if folder is in shortcut directory): "
 
: REM i.e. shortcut is C:short (in DOSBox) and file is C:\folder\file
 
: REM i.e. shortcut is C:short (in DOSBox) and file is C:\folder\file
Line 32: Line 33:
  
 
:: ''if errorlevel 2 set /P folder="Enter the name of the program folder: "''
 
:: ''if errorlevel 2 set /P folder="Enter the name of the program folder: "''
:: ''if errorlevel 1 set folder=%program%''
+
:: ''if errorlevel 1'' '''''set folder=%program%'''''
 
: ''choice /m "Do you want the shortcut to have the same name as the program file"''
 
: ''choice /m "Do you want the shortcut to have the same name as the program file"''
  
 
:: ''if errorlevel 2 set /P shortcut="Enter the name of the shortcut: "''
 
:: ''if errorlevel 2 set /P shortcut="Enter the name of the shortcut: "''
:: ''if errorlevel 1 set shortcut=%program%''
+
:: ''if errorlevel 1'' '''''set shortcut=%program%'''''
 
: ''choice /m "Do you want the shortcut to have the same name as the file"''
 
: ''choice /m "Do you want the shortcut to have the same name as the file"''
  
 
:: ''if errorlevel 2 set /P shortcut="Enter the name you want for the shortcut: "''
 
:: ''if errorlevel 2 set /P shortcut="Enter the name you want for the shortcut: "''
:: ''if errorlevel 1 set shortcut=%file%''
+
:: ''if errorlevel 1'' '''''set shortcut=%file%'''''
 
: ''choice /m "Is the file on the current drive"''
 
: ''choice /m "Is the file on the current drive"''
 
:: ''if errorlevel 2 set /P drive="Enter the correct drive letter: "''
 
:: ''if errorlevel 2 set /P drive="Enter the correct drive letter: "''
:: ''if errorlevel 1 set drive=null
+
:: ''if errorlevel 1 set drive=null''
: ''if exist .\%shortcut%.bat goto error1
+
: ''write''
  
: ''echo @echo off >> %shortcut%.bat''
+
:: ''if exist .\%shortcut%.bat goto error1''
 +
: '': override''
 +
 
 +
: '''''echo @echo off >> %shortcut%.bat'''''
 
:: ''if not %drive%==null echo %drive%:\ >> %shortcut%.bat''
 
:: ''if not %drive%==null echo %drive%:\ >> %shortcut%.bat''
: ''echo cd %folder% >> %shortcut%.bat''
+
: '''''echo cd %folder% >> %shortcut%.bat'''''
: ''echo %program% >> %shortcut%.bat''
+
: '''''echo %program% >> %shortcut%.bat'''''
: ''echo cd \ >> %shortcut%.bat''
+
: '''''echo cd \ >> %shortcut%.bat'''''
 +
 
 +
:: ''if not exist .\%shortcut%.bat goto error2
  
: ''write''
 
: ''if not exist .\%shortcut%.bat goto error2
 
  
: '': override
+
:: ''if not %drive%==null echo A shortcut to the file %file% in the folder %folder% on drive %drive%:\ with the name %shortcut% has been created''
:: ''if not %drive%==null echo A shortcut to the file %file% in the folder %folder% on drive %drive%:\ with the name %shortcut%''
+
:: ''if %drive%==null'' '''''echo A shortcut to the file %file% in the folder %folder% with the name %shortcut% has been created'''''
:: ''if %drive%==null echo A shortcut to the file %file% in the folder %folder% with the name %shortcut%''
+
: '''''echo "To run %file% just type %shortcut%"'''''  
: ''echo "To run %file% just type %shortcut%"''  
+
 
: ''goto end''
 
: ''goto end''
  
Line 65: Line 68:
 
: ''echo error (1): there is already a file with the name %shortcut% in this folder''
 
: ''echo error (1): there is already a file with the name %shortcut% in this folder''
 
: ''choice /m "overwrite file"''
 
: ''choice /m "overwrite file"''
: ''if not errorlevel 2 goto override''
+
:: ''if not errorlevel 2 goto override''
 
: ''choice /m "chose another name for your shortcut"''
 
: ''choice /m "chose another name for your shortcut"''
: ''if errorlevel 1 set /P shortcut="Enter the name you want for the shortcut: "''
+
:: ''if errorlevel 1 set /P shortcut="Enter the name you want for the shortcut: "''
: ''if errorlevel 1 goto : ''write''
+
:: ''if errorlevel 1 goto : ''write''
 
: ''goto end''
 
: ''goto end''
  
Line 76: Line 79:
  
 
: '': end''
 
: '': end''
: ''pause''
+
: '''''pause'''''

Revision as of 00:25, 29 January 2012

  • This will allow you to use a shortcut to your program using a batch file that you run in DOSBox it's self.
  • This way you can keep you mount settings
  • Create in the root directory of the folder you use primarily for DOSBox a text file and rename it [program].bat
  • Open it in notepad and type
    • @echo off
cd [program dir]
[program]
cd \
REM once the program is closed this will take you back to the root directory
  • To run it (provided your autoexec has something like "mount C C:\folder", C:\ and [program].bat is in C:\folder) just type [program].
  • So for theme hospital that would be 'hospital.bat' and
    • @echo off
cd hospital
hospital
cd \
  • and to run it all you need to do is type 'hospital'.
  • If autoexec is empty then you will need to add the lines
    • mount C C:\folder
and
C:\

A Small Shortcut Maker

  • You can write a program to do this quickly
  • Unfortunately this can't be run from dosbox due to the set /P command not being supported by DOS 6.22 (if there is a native command that will allow for the input of a string then feel free to modify the code you will also have to change the choice syntax from choice [/m "text"] to choice [text])
  • Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and write this to it
  • The important parts of the code are in bold
    • @echo off
set /P file="Enter the name of the program: "
choice /m "Does the program folder have the same name as the program file (only if folder is in shortcut directory): "
REM i.e. shortcut is C:short (in DOSBox) and file is C:\folder\file
REM say no if folder is C:\prog\folder\file and if shortcut is in C:\shortf\short use the full path
if errorlevel 2 set /P folder="Enter the name of the program folder: "
if errorlevel 1 set folder=%program%
choice /m "Do you want the shortcut to have the same name as the program file"
if errorlevel 2 set /P shortcut="Enter the name of the shortcut: "
if errorlevel 1 set shortcut=%program%
choice /m "Do you want the shortcut to have the same name as the file"
if errorlevel 2 set /P shortcut="Enter the name you want for the shortcut: "
if errorlevel 1 set shortcut=%file%
choice /m "Is the file on the current drive"
if errorlevel 2 set /P drive="Enter the correct drive letter: "
if errorlevel 1 set drive=null
write
if exist .\%shortcut%.bat goto error1
: override
echo @echo off >> %shortcut%.bat
if not %drive%==null echo %drive%:\ >> %shortcut%.bat
echo cd %folder% >> %shortcut%.bat
echo %program% >> %shortcut%.bat
echo cd \ >> %shortcut%.bat
if not exist .\%shortcut%.bat goto error2


if not %drive%==null echo A shortcut to the file %file% in the folder %folder% on drive %drive%:\ with the name %shortcut% has been created
if %drive%==null echo A shortcut to the file %file% in the folder %folder% with the name %shortcut% has been created
echo "To run %file% just type %shortcut%"
goto end
REM error messages and codes
: error1
echo error (1): there is already a file with the name %shortcut% in this folder
choice /m "overwrite file"
if not errorlevel 2 goto override
choice /m "chose another name for your shortcut"
if errorlevel 1 set /P shortcut="Enter the name you want for the shortcut: "
if errorlevel 1 goto : write
goto end
: error2
echo error (2): file creation failed
goto end
: end
pause