Difference between revisions of "Shortcuts that You Run in DOSBox"
From DOSBoxWiki
Jump to navigationJump to searchHHaddow990 (talk | contribs) (→A Small Shortcut Maker: debugged code works on windows 7 but still not in dos, moved the file writing code to the end of the file) |
HHaddow990 (talk | contribs) |
||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
* This will allow you to use a shortcut to your program using a batch file that you run in DOSBox it's self. | * 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''' | * '''This way you can keep you mount settings''' | ||
+ | |||
+ | You may also want to read [[DOSBoxShortcuts|DOSBox Shortcuts]] | ||
+ | |||
+ | = Making the Shortcuts = | ||
+ | |||
* Create in the root directory of the folder you use primarily for DOSBox a text file and rename it [program].bat | * 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 | * Open it in notepad and type | ||
− | ** ''@echo off'' | + | ** ''@echo off'' |
: ''cd [program dir]'' | : ''cd [program dir]'' | ||
: ''[program]'' | : ''[program]'' | ||
: ''cd \ | : ''cd \ | ||
− | : REM once the program is closed this will take you back to the root directory | + | : 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]. | * 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 | * So for theme hospital that would be 'hospital.bat' and | ||
Line 24: | Line 28: | ||
* You can write a program to do this quickly | * 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 | + | * Unfortunately this version can't be run from dosbox due to the set /P command not being supported by DOS 6 and some other syntax changes if you follow the link at the bottom of the page you can download a dos version that uses Horst's INPUT.COM |
− | * Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and | + | * Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and copy this to it |
+ | * The important parts of the code are in '''bold''' | ||
** ''@echo off'' | ** ''@echo off'' | ||
− | : ''set /P | + | : '': start'' |
− | : ''choice /m "Does the program folder have the same name as the program file" | + | : '''''set /P file="Enter the name of the program: "''''' |
− | : ''if errorlevel 1 set folder=%program%'' | + | : ''choice /m "Does the program folder have the same name as the program file (only if folder is in shortcut directory): " |
− | : ''if errorlevel 2 set /P folder="Enter the name of the program folder: "'' | + | : REM i.e. shortcut is C:short (in DOSBox) and file is C:\folder\file |
− | : ''echo @echo off > % | + | : REM say no if folder is C:\prog\folder\file and if shortcut is in C:\shortf\short use the full path |
− | : ''echo cd %folder% >> % | + | :: ''if errorlevel 1'' '''''set folder=%program%''''' |
− | : ''echo %program% >> % | + | :: ''if errorlevel 2 set /P folder="Enter the name of the program folder: "'' |
− | : ''echo cd \ >> % | + | |
+ | : ''choice /m "Do you want the shortcut to have the same name as the program file"'' | ||
+ | :: ''if errorlevel 1'' '''''set shortcut=%program%''''' | ||
+ | :: ''if errorlevel 2 set /P shortcut="Enter the name of the shortcut: "'' | ||
+ | |||
+ | : ''choice /m "Do you want the shortcut to have the same name as the file"'' | ||
+ | :: ''if errorlevel 1'' '''''set shortcut=%file%''''' | ||
+ | :: ''if errorlevel 2 set /P shortcut="Enter the name you want for the shortcut: "'' | ||
+ | |||
+ | : ''choice /m "Is the file on the same drive as the shortcut"'' | ||
+ | :: ''if errorlevel 1 set drive=null'' | ||
+ | :: ''if errorlevel 2 set /P drive="Enter the correct drive letter: "'' | ||
+ | |||
+ | : ''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 again'' | ||
+ | |||
+ | : 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'' | ||
+ | |||
+ | : '': again'' | ||
+ | : ''choice /m "do you want to create another shortcut"'' | ||
+ | : ''if errorlevel 2 goto end'' | ||
+ | : ''goto start'' | ||
+ | |||
+ | : '': end'' | ||
+ | : '''''pause''''' | ||
+ | |||
+ | * This has been tested and run in windows 7 other versions may need some small syntax changes | ||
+ | * I have created two copies of the file one runs in dos and the other is the above code (windows) both of which can be found [http://hhaddow.co.uk/?article=3 here] | ||
+ | * To allow this to run in DOSBox you will need to download INPUT.com from [http://www.horstmuc.de/horst.htm Horstmuc.de] (under Pbats) and place it in the same folder as short.bat |
Latest revision as of 09:54, 3 February 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
You may also want to read DOSBox Shortcuts
Making the Shortcuts
- 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 version can't be run from dosbox due to the set /P command not being supported by DOS 6 and some other syntax changes if you follow the link at the bottom of the page you can download a dos version that uses Horst's INPUT.COM
- Create a batch file in the directory you want the shortcuts to be in lets call it short.bat and copy this to it
- The important parts of the code are in bold
- @echo off
- : start
- 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 1 set folder=%program%
- if errorlevel 2 set /P folder="Enter the name of the program folder: "
- choice /m "Do you want the shortcut to have the same name as the program file"
- if errorlevel 1 set shortcut=%program%
- if errorlevel 2 set /P shortcut="Enter the name of the shortcut: "
- choice /m "Do you want the shortcut to have the same name as the file"
- if errorlevel 1 set shortcut=%file%
- if errorlevel 2 set /P shortcut="Enter the name you want for the shortcut: "
- choice /m "Is the file on the same drive as the shortcut"
- if errorlevel 1 set drive=null
- if errorlevel 2 set /P drive="Enter the correct drive letter: "
- 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 again
- 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
- : again
- choice /m "do you want to create another shortcut"
- if errorlevel 2 goto end
- goto start
- : end
- pause
- This has been tested and run in windows 7 other versions may need some small syntax changes
- I have created two copies of the file one runs in dos and the other is the above code (windows) both of which can be found here
- To allow this to run in DOSBox you will need to download INPUT.com from Horstmuc.de (under Pbats) and place it in the same folder as short.bat