How can I get my batch file to run?

Chas H August 16, 2013
Pinterest Stumbleupon Whatsapp
Ads by Google

My file, net.bat, was created with notepad and saved as netbat and type “All Files”, but when I click on it, it opens in WordPad. Several years ago, I used to write bat files all the time. I am sure that I am doing something silly. Hope you can help, as I would like to write several more bat files.

  1. Jonny
    August 18, 2013 at 10:13 am

    Net is a reserved word in windows.
    Change the file name to NetInfo.bat or shownet.bat

    Good luck.

  2. Chas H
    August 17, 2013 at 12:59 am

    Jan F.

    You got it!!!!!
    That was the problem with each file. I sure learned a few things from this exercise. Thank you, everyone for helping with this problem.

    Best wishes to everyone -

    Chas

  3. Chas H
    August 16, 2013 at 10:15 pm

    Thank you for writing an answer for this question! I deleted the UserChoice key, but the file still opened in WordPad. The file name is net.bat and is on my desktop. This is the entire file from Notepad.

    ———–Start Code———–

    :: ECHO OFF
    :: CMD will no longer show us what command it’s executing(cleaner)
    ECHO As a network admin, I’m getting tired of having to type these commands in! Hopefully, this saves me some time in the long run.
    :: Print some text
    IPCONFIG /ALL
    :: Outputs tons of network information into the command prompt
    PAUSE
    :: Lets the user read the important network information
    PING http://www.google.com
    :: Ping google to figure out if we’ve got internet!
    ECHO All done pinging Google.
    :: Print some text
    PAUSE
    :: Give the user some time to see the results. Because this is our last line, the program will exit and the command window will close once this line finishes.

    ———–End Code———–

    I appreciate your efforts.

    Chas

  4. Jan F
    August 16, 2013 at 9:47 pm

    My first guess would be that you have a "double-extension" resulting in the '.bat' being ignored.

    click Start > Control Panel, go to Appearance and Personalization, then Folder options
    disable "hide file extensions for known file types"

    Now make sure the actual file extension for your file is '.bat' and not something like 'net.bat.txt"

  5. Bruce E
    August 16, 2013 at 8:38 pm

    If the filename you used was typed correctly in your description of the problem, a missing period is the issue. Your file should be "net.bat" instead of "netbat." Microsoft operating systems use the file extension to determine the type of file and without the dot, it leaves you with a file without any extension which, depending on the system configuration, will end up opening up in a text editor (NotePad, WordPad, etc).

    There is also another possibility: that the default application for .bat files was changed to WordPad when previously opening a .bat file that didn't have that association set up. To fox this, you need to run regedt32.exe as an administrator (Start - type 'regedt32.exe' in the search box, when it appears in the upper portion of the menu, right-click on it and select 'Run as administrator'). Navigate to the key HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.BATUserChoice. Delete the UserChoice key. This will cause it to revert to the default behavior for your batch files (running them).