Windows 10: Creating a Batch File Example

Discus and support Creating a Batch File Example in Windows 10 Support to solve the problem; Hey All, I am not looking for someone to do the work for me, I'm trying to get a general idea of what I need to start at. It's been a few years since... Discussion in 'Windows 10 Support' started by ulricken, Jul 27, 2021.

  1. ulricken Win User

    Creating a Batch File Example


    Hey All, I am not looking for someone to do the work for me, I'm trying to get a general idea of what I need to start at. It's been a few years since I've done a batch file and Windows 10 is so different than Windows 7. I am essentially wanting a batch file, that if I type a Store Number it will do a ping on the store's IP Addresses. (IPs were changed to DNS Servers to enhance privacy). Here's what I'm working with.. Below is what I get as the error. Ultimately, what I want is to type in the store number and it ping the VLAN Gateways as well as the Register, PinPads, etc. Each device gets pinged 4 times.. @Echo off :STRNUM set /p strnum="What is the Store Number?" If "%strnum%"=="09424" GOTO :9424PING :9424PING ipadd_vlan1gw == "8.8.8.8" ipadd_vlan2gw == "8.8.4.4" ipadd_vlan3gw == "4.2.2.2" ipadd_vlan6gw == "208.67.222.222" ping %ipadd_vlan1gw% pausegoto Creating a Batch File Example :pING Again, I am not looking for someone to solve it for me, but rather point me in the right direction for me to do it myself. Would it be easier if I took the IPs and put them in a .txt file and have the batch script reference that? Any thoughts/ideas would be greatly appreciated!

    :)
     
    ulricken, Jul 27, 2021
    #1
  2. oily_17 Win User

    Batch Files Knowledge Base

    Don't use batch files very much but one I find useful is for creating a list of files in a directory.
    Just copy the text below into Notepad and save as Filelist.bat

    dir /a /-p /o:gen >filelist.txt

    When you run it from a folder it will create a Filelist.txt file,in the same folder, that lists all the files in that folder.Useful when you are too lazy to type all the files out yourself.
     
    oily_17, Jul 27, 2021
    #2
  3. Batch Files Knowledge Base

    Very nice and usefull thanks for contributing.
     
    AphexDreamer, Jul 27, 2021
    #3
  4. Flava0ne Win User

    Creating a Batch File Example

    Creating Shortcuts with Batch File

    I've created a Batch file which calls on the following VB Script to be able to create a shortcut to my desktop:

    VB Script (named createLink.vbs):
    Code: set objWSHShell = CreateObject("WScript.Shell") set objFso = CreateObject("Scripting.FileSystemObject") ' command line arguments ' TODO: error checking sShortcut = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(0)) sTargetPath = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(1)) sWorkingDirectory = objFso.GetAbsolutePathName(sShortcut) set objSC = objWSHShell.CreateShortcut(sShortcut) objSC.TargetPath = sTargetPath objSC.WorkingDirectory = sWorkingDirectory objSC.Save[/quote] Batch File Example (for Windows Notepad):
    Code: @Echo off cscript createLink.vbs "C:\Users\Administrator\Desktop\Notepad.lnk" "C:\Windows\System32\notepad.exe"[/quote] But after creating the shortcut using this method, I'm not able to assign a custom icon for the shortcut. I get the following error message when trying to do so:


    Creating a Batch File Example Error503.jpg


    Any help and ideas on what I need to put into the VB Script and/or Batch File to be able to do this would be greatly appreciated! *Big Grin Creating a Batch File Example :D

    Also, I know that I can simply do this by going to Start Menu\All Programs\Accessories\ right-clicking on Notepad and selecting Send to\Desktop (create shortcut). Easy enough for creating a single shortcut. But I need to create several multiple shortcuts and using this Batch/VBS method would really save me a lot of time in doing so.
     
    Flava0ne, Jul 27, 2021
    #4
Thema:

Creating a Batch File Example

Loading...
  1. Creating a Batch File Example - Similar Threads - Creating Batch File

  2. Creating a batch file to send the label files to the printer

    in Windows 10 Support
    Creating a batch file to send the label files to the printer: is it possible to create a bat file to print a barcode label? 178788
  3. Need help to create a batch file

    in Windows 10 Support
    Need help to create a batch file: Hi Folks, I need to create a batch file that automatically takes permissions & delete the following file & folders File:- C:\Windows\System32\SecurityHealthSystray.exe Folders:-...
  4. How to create a batch file for network printer

    in Windows 10 Drivers and Hardware
    How to create a batch file for network printer: How to create batch file for several network printers? I used the below info, but when I entered several printers only the first one worked. %SystemRoot%\explorer.exe \\ServerName\PrinterName...
  5. Create batch files with Batch?

    in Windows 10 Software and Apps
    Create batch files with Batch?: How to create Batch and VBS files with Batch? So I write a batch file which I then convert to exe that creates new folders in a certain directory and then creates batch and VBS files with a certain content and saves them in the created folder. So it's similar to a program...
  6. Batch Files

    in Windows 10 Network and Sharing
    Batch Files: I want to make a batch file that will copy a specific folder from my USB stick to a folder on C:\ I want to know if it's possible to make a batch file that will take the folder from my USB drive no matter what the drive's letter is....
  7. Batch Files

    in Windows 10 Network and Sharing
    Batch Files: I cannot remember how to open a FILE browser in batch, i was trying to create something were it opens a file browser, and the file you click on, gets deleted. https://answers.microsoft.com/en-us/windows/forum/all/batch-files/335a0e0d-62b0-4615-b303-4a7bb548cc6c"
  8. batch file

    in Windows 10 Network and Sharing
    batch file: I want a BAT file to be executed when a USB plugged in to the PC. How can I do it? https://answers.microsoft.com/en-us/windows/forum/all/batch-file/1af5ec02-b6c8-4916-959b-ed0327a964e7"
  9. Create Multipurpose batch file

    in Windows 10 Software and Apps
    Create Multipurpose batch file: Hope this is the correct sub forum for this.. Often use a variety of command line functions e.g. winver / netplwiz etc etc Is there a way of creating a batchfile to include multiple commands with a number option to select...would be so handy i.e. 1 Netplwiz 2 Winver...
  10. Include date in file created by batch file.

    in Windows 10 Support
    Include date in file created by batch file.: How can I add to this batch command to include the date: xcopy C:\all\* Z:\Allbak\* /E /Y /C I'd like the resulting file to be named "Z:\Allbak171129" (yr mo day). The plan is to set up a task schedule to run the batch file every week. I want to keep several previous...