Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    2 Star Lounger
    Join Date
    Aug 2014
    Posts
    123
    Thanks
    19
    Thanked 0 Times in 0 Posts

    How to run a dos/batch file

    Have this 8.1 running on a Toshiba Satellite and getting re-used to DOS.
    Have a example DOS text file created in NOTEPAD. How can I run this?
    Tried path\file but didn't work.
    How do I convert this to a batch file and run the batch file? Is it just a rename? Have forgotten so much. A tutorial URL would be nice.

  2. #2
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    This one doesn't look too bad http://www.computerhope.com/batch.htm and in this article is an example of a simplified type http://secure-computer-solutions.com...ernet_c_1.html

    Googling how do I create a batch file produces a number of links.

    I think the main part is to save it as All Files (*.*) otherwise it's just saved as a txt file in Notepad.
    Last edited by Sudo15; 2014-10-23 at 04:56.

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Spark,

    When saving the file in Notepad enclose the entire filename in double quotes and use a file type of .bat or prefered IMHO .cmd.

    Ex: "MyCommands.cmd"

    HTH

    FWIW: You could also upgrade your skill set to PowerShell.
    Last edited by RetiredGeek; 2014-10-23 at 08:10.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. #4
    3 Star Lounger
    Join Date
    May 2010
    Location
    Philadelphia, PA, USA
    Posts
    208
    Thanks
    3
    Thanked 27 Times in 26 Posts
    Why are you trying to do this? Is it to actually run a DOS program? Have you tried to run the program in Windows 8.1? Is it a 64-bit version - many older programs will not run in 64-bit Windows.

    Make sure you save the file using DOS restrictions. It should have an extension of .BAT. You can check this by looking at the file name in Windows - make sure you enable file extensions. Put it in the same folder as the program.

  5. #5
    2 Star Lounger
    Join Date
    Aug 2014
    Posts
    123
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Thanxs for the comments!!
    Got a .bat file to execute. But netsh wlan show networks mode=bssid works from the command line but not from a .bat file.
    Any ideas?

    Are there any open source development tools for Dos/Batch under Notepad? or where notepad is the central function?

    Looked at powershell and found it to be an aborted hack of the tried and true *nix Bourne/bash shell.

  6. #6
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    The "show networks" command doesn't require elevation from the command prompt but batch files usually need to be run as an administrator by right clicking on them and selecting Run as administrator - does that make any difference to the file executing, although that command produces an output in the command window and could be baulking because of other commands you have included.

    Does it execute when that is the only command in the batch file ?

  7. #7
    WS Lounge VIP Coochin's Avatar
    Join Date
    Jun 2014
    Location
    Queensland, Australia
    Posts
    2,157
    Thanks
    31
    Thanked 307 Times in 267 Posts
    Quote Originally Posted by Sudo15 View Post
    ...I think the main part is to save it as All Files (*.*) otherwise it's just saved as a txt file in Notepad...
    Not quite.

    In Notepad save it as "Example.bat" (with the quotes) in the "File name" field, and change the "Save as type" selection to "All files". If you just type "Example.bat" in the "File name" field and do not change the "Save as type" selection to "All files" the file will be saved as "Example.bat.txt".

    As should be obvious change "Example" to suit your preference.
    Last edited by Coochin; 2014-10-30 at 05:40.
    Computer Consultant/Technician since 1998 (first PC was Atari 1040STE in 1988).
    Most common computing error is EBKAC: Error Between Keyboard And Chairback
    AMD FX8120 (8-core @ 3.1GHz) CPU, Gigabyte GA-990FXA-D3 motherboard, 8GB (2x4GB) DDR3 1866MHz RAM, ATI-AMD Radeon HD6770 PCI-E VGA, 480GB Kingston SSD, 2TB Seagate SATA3.0 HDD, ASUS DVD/RW.

  8. #8
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    Quote Originally Posted by Coochin View Post
    Not quite.

    In Notepad save it as "Example.bat" (with the quotes) in the "File name" field, and change the "Save as type" selection to "All files". If you just type "Example.bat" in the "File name" field and do not change the "Save as type" selection to "All files" the file will be saved as "Example.bat.txt".

    As should be obvious change "Example" to suit your preference.
    I did say the main part....

  9. #9
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Hey Y'all,

    I don't know what all this stuff about the Save as Type is about but I've tested this and if you enclose the file name in quotes ("Test.bat") the program executes as it should with either the .bat or .cmd extensions. This was tested on Windows 8.1 Update 1 & Win 10 TP. Also there is no .txt appended to the end in File Explorer.
    TestingNotepadSave.JPG
    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. The Following 2 Users Say Thank You to RetiredGeek For This Useful Post:

    Coochin (2014-10-30),Sudo15 (2014-10-30)

  11. #10
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    I once copied some instructions for a batch file but missed the bit about saving it as All File Types, so it just saved as a txt file - although there was no mention of putting the file name in quotes and this would seem to be an alternative method.

  12. #11
    WS Lounge VIP Coochin's Avatar
    Join Date
    Jun 2014
    Location
    Queensland, Australia
    Posts
    2,157
    Thanks
    31
    Thanked 307 Times in 267 Posts
    Quote Originally Posted by RetiredGeek View Post
    Hey Y'all,

    I don't know what all this stuff about the Save as Type is about but I've tested this and if you enclose the file name in quotes ("Test.bat") the program executes as it should with either the .bat or .cmd extensions. This was tested on Windows 8.1 Update 1 & Win 10 TP. Also there is no .txt appended to the end in File Explorer...
    My habit of changing "Save as type" to "All files" when saving .bat files from Notepad goes way back to the "good old days?" of Win95 & Win98.
    Computer Consultant/Technician since 1998 (first PC was Atari 1040STE in 1988).
    Most common computing error is EBKAC: Error Between Keyboard And Chairback
    AMD FX8120 (8-core @ 3.1GHz) CPU, Gigabyte GA-990FXA-D3 motherboard, 8GB (2x4GB) DDR3 1866MHz RAM, ATI-AMD Radeon HD6770 PCI-E VGA, 480GB Kingston SSD, 2TB Seagate SATA3.0 HDD, ASUS DVD/RW.

  13. #12
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    Quote Originally Posted by Coochin View Post
    My habit of changing "Save as type" to "All files" when saving .bat files from Notepad goes way back to the "good old days?" of Win95 & Win98.
    Mine just goes back to the good old days of win 7

  14. #13
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Yeah,

    That's when I just used WordPerfect and saved as DOS type file! Or in a pinch EDLIN! (yeah I'm that OLD)
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  15. #14
    Silver Lounger
    Join Date
    Mar 2014
    Location
    Forever West
    Posts
    2,078
    Thanks
    0
    Thanked 259 Times in 248 Posts
    Back in 'the good ole days' of MS-DOS 5 ['92] I used batch/.bat files to do things such as a directory list using dir>dir.txt. It always saved the screen contents of dir as text, or if wanting to print it I'd use dir>prn. If wanting to see the results of a .bat file run from a Command Prompt window [in Win95 and later], it works to put the word Pause as the last line or the .bat file would run then close too fast to read. The .bat file can be created in Notepad, not in a word processor, and saved as the name and extension of .bat. Notepad is a text editor and does not add hidden coding while a word processor does. The > is a redirect from the screen to whatever chosen.

  16. #15
    Super Moderator
    Join Date
    Aug 2012
    Location
    Durham UK
    Posts
    6,645
    Thanks
    147
    Thanked 884 Times in 845 Posts
    Quote Originally Posted by RetiredGeek View Post
    Yeah,

    That's when I just used WordPerfect and saved as DOS type file! Or in a pinch EDLIN! (yeah I'm that OLD)
    I think I may have been learning WP 5.1 and DB 3 then - forget what the Excel version was - circa '94

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •