Solved Bat files and scripts


The-Hive

The First Three Star Guru
Guru
VIP
Local time
3:35 AM
Posts
11,293
Location
Wiltshire UK
OS
Windows 11 Pro
Can anyone suggest any good sites or sources where I can learn (get a better understanding)m of creating and using bat files and scripts. Thanks
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Alienware Area 51m R2
    CPU
    10th Gen Core i9 10900K
    Memory
    32GB
    Graphics Card(s)
    Geforce RTX 2080 Super
    Sound Card
    Nvidia HD
    Screen Resolution
    1920x1080
    Hard Drives
    C: Samsung 2TB P981A
    D: Samsung 2TB 970 Evo
    Case
    Dark side of the moon
    Mouse
    Alienware AW610M
    Browser
    Chrome and Firefox
    Antivirus
    Norton
    Other Info
    Killer E3000 Ethernet Controller
    Killer AX1650i Wi-Fi Network Adaptor
    Alienware Z01G Graphic Amplifier
    Tobii Eye Tracker
  • Operating System
    Dual Boot Windows 11 Pro / Windows 11 Pro Dev build
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron 3501
    CPU
    11th Gen i-7 2.80 gb
    Memory
    16Gb
    Screen Resolution
    1920 x 1080
    Hard Drives
    512Gb SSD
    WD 2GB EXT
    Browser
    Chrome
    Antivirus
    Norton

Berton

Well-known member
Power User
VIP
Local time
8:35 PM
Posts
1,027
Location
Buffalo, Wyoming
OS
Win11 Pro RTM
Might start with a search for DOS Commands. DOS has a lot of commands and switches for them, put dir /? in a Command Prompt window to get examples of a list of files in a folder and how they are listed. A number of DOS commands still work in Windows. I've not gotten as familiar with scripts yet or PowerShell. My first computer was in '92 with MS-DOS 5 and Windows 3.1, two years later was building them, still have an old Notebook with it except updated to MS-DOS 6.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5
    Memory
    8GB
    Hard Drives
    256GB SSD NVMe
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    21"
    Hard Drives
    512GB SSD NVMe, 2TB WDC HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security

The-Hive

The First Three Star Guru
Guru
VIP
Thread Starter
Local time
3:35 AM
Posts
11,293
Location
Wiltshire UK
OS
Windows 11 Pro
I worked with dos scripts so many years ago I forgot
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Alienware Area 51m R2
    CPU
    10th Gen Core i9 10900K
    Memory
    32GB
    Graphics Card(s)
    Geforce RTX 2080 Super
    Sound Card
    Nvidia HD
    Screen Resolution
    1920x1080
    Hard Drives
    C: Samsung 2TB P981A
    D: Samsung 2TB 970 Evo
    Case
    Dark side of the moon
    Mouse
    Alienware AW610M
    Browser
    Chrome and Firefox
    Antivirus
    Norton
    Other Info
    Killer E3000 Ethernet Controller
    Killer AX1650i Wi-Fi Network Adaptor
    Alienware Z01G Graphic Amplifier
    Tobii Eye Tracker
  • Operating System
    Dual Boot Windows 11 Pro / Windows 11 Pro Dev build
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron 3501
    CPU
    11th Gen i-7 2.80 gb
    Memory
    16Gb
    Screen Resolution
    1920 x 1080
    Hard Drives
    512Gb SSD
    WD 2GB EXT
    Browser
    Chrome
    Antivirus
    Norton

TairikuOkami

Brony
Power User
VIP
Local time
4:35 AM
Posts
495
OS
Windows 11 Home

My Computer

System One

  • OS
    Windows 11 Home
    CPU
    AMD Ryzen 5 3600 (07/19)
    Motherboard
    MSI B450 TOMAHAWK 7C02v1E (07/19)
    Memory
    4x 8GB ADATA XPG GAMMIX D10 DDR4 3200MHz CL16
    Graphics Card(s)
    MSI Radeon RX 580 ARMOR 8G OC (08/19)
    Sound Card
    Creative Sound Blaster Z (11/16)
    Monitor(s) Displays
    24" AOC G2460VQ6 (01/19)
    Screen Resolution
    1920×1080@75Hz + FreeSync (DisplayPort)
    Hard Drives
    ADATA XPG GAMMIX S11 Pro SSD 512GB (07/19)
    PSU
    Seasonic M12II-520 80 Plus Bronze (11/16)
    Case
    Lian Li PC-7NB + 3x Noctua NF-S12A FLX@700rpm (11/16)
    Cooling
    CPU Cooler Noctua NH-U12S@700rpm
    Keyboard
    HP Wired Desktop 320K Keyboard (04/22)
    Mouse
    HP Wireless Silent 280M Mouse (05/21)
    Internet Speed
    400/40 Mbps via RouterOS (05/21) + TCP Optimizer
    Browser
    Edge with SwissCows (No FB/Google) + Brave for YouTube + LibreWolf for FB
    Antivirus
    None + Binisoft WFC
    Other Info
    Headphones: Sennheiser RS170 (09/10)

Bree

Well-known member
Guru
VIP
Local time
3:35 AM
Posts
6,197
Location
S/E England, UK
OS
Windows 11 Home
I worked with dos scripts so many years ago I forgot
little has changed, that's where I learned to script too. What you learned in DOS is equally applicable today. Try a refresher course....

 

My Computers

System One System Two

  • OS
    Windows 11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Acer Aspire 3 A315-23
    CPU
    AMD Athlon Silver 3050U
    Memory
    8GB
    Graphics Card(s)
    Radeon Graphics
    Monitor(s) Displays
    laptop screen
    Screen Resolution
    1366x768 native resolution, up to 2560x1440 with Radeon Virtual Super Resolution
    Hard Drives
    1TB Samsung EVO 870 SSD
    Browser
    Edge, Firefox
    Antivirus
    Defender
    Other Info
    fully 'Windows 11 ready' laptop. Windows 10 C: partition migrated from my old unsupported 'main machine' then upgraded to 11. A test migration ran Insider builds for 2 months. When 11 was released on 5th October it was re-imaged back to 10 and was offered the upgrade in Windows Update on 20th October.

    My SYSTEM THREE is a Dell Latitude 5410, i7-10610U, 32GB RAM, 512GB ssd, Windows 11 Pro.

    My SYSTEM FOUR is a 2-in-1 convertible Lenovo Yoga 11e 20DA, Celeron N2930, 4GB RAM, 128GB ssd. Unsupported device: currently running Win10 Pro, plus Win11 Pro 22H2 RTM as a native boot vhdx.
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Dell Lattitude E4310
    CPU
    i5 M 520
    Motherboard
    0T6M8G
    Memory
    4GB
    Screen Resolution
    1366x768
    Hard Drives
    500GB HDD
    Browser
    Firefox, Edge
    Antivirus
    Defender
    Other Info
    unsupported machine: Legacy bios, MBR, TPM 1.2, upgraded from W10 to W11 using W10/W11 hybrid install media workaround.

    My SYSTEM THREE is a Dell Latitude 5410, i7-10610U, 32GB RAM, 512GB ssd, Windows 11 Pro.

    My SYSTEM FOUR is a 2-in-1 convertible Lenovo Yoga 11e 20DA, Celeron N2930, 4GB RAM, 128GB ssd. Unsupported device: currently running Win10 Pro, plus Win11 Pro 22H2 RTM as a native boot vhdx.

The-Hive

The First Three Star Guru
Guru
VIP
Thread Starter
Local time
3:35 AM
Posts
11,293
Location
Wiltshire UK
OS
Windows 11 Pro
Thanks @Bree As I got older, things get harder to sink in:(
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Alienware Area 51m R2
    CPU
    10th Gen Core i9 10900K
    Memory
    32GB
    Graphics Card(s)
    Geforce RTX 2080 Super
    Sound Card
    Nvidia HD
    Screen Resolution
    1920x1080
    Hard Drives
    C: Samsung 2TB P981A
    D: Samsung 2TB 970 Evo
    Case
    Dark side of the moon
    Mouse
    Alienware AW610M
    Browser
    Chrome and Firefox
    Antivirus
    Norton
    Other Info
    Killer E3000 Ethernet Controller
    Killer AX1650i Wi-Fi Network Adaptor
    Alienware Z01G Graphic Amplifier
    Tobii Eye Tracker
  • Operating System
    Dual Boot Windows 11 Pro / Windows 11 Pro Dev build
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron 3501
    CPU
    11th Gen i-7 2.80 gb
    Memory
    16Gb
    Screen Resolution
    1920 x 1080
    Hard Drives
    512Gb SSD
    WD 2GB EXT
    Browser
    Chrome
    Antivirus
    Norton

Try3

Well-known member
Power User
VIP
Local time
3:35 AM
Posts
832
Location
The proper part of London
OS
Windows 11 Home x64 Version 21H2 Build 22000.978
Here are some Batch file guides -

Here's an introduction to batch files
The Command Line in Windows Batch file basics

Here are some guides by the excellent RobvdWoude
Batch files - RobvdW
Batch File Scripting Techniques - RobvdW
Batch Files Examples - RobvdW

Here are some reference guides on individual commands
<command> /? produces an up-to-date Help file for most commands, this is the only known source for up-to-date, Windows10/11-specific Help.
Windows commands - MSDocs {note that the guidance might reflect variants of the command such as older versions or non-WIndows10/11 versions}
Windows command index - SS64 {note that the guidance might reflect variants of the command such as older versions or non-WIndows10/11 versions}
Commands forum - SS64
Just to emphasise the variants point, the Windows 10 netsh command is a significant step forward from its earlier versions but there is no online guide for this version. All online netsh guides are out-of-date or refer to non-Windows10 variants of the command.
So far, I've only found one command that ran in Windows 10 but does not run in Windows 11 - Nbtstat


my ditty and demo for: Manipulating variables in batch files [post #14] - TenForums
my ditty and demo for: Standard passable variables [post #47] - TenForums
my ditty and demo for: The need to use quotes with paths containing spaces [post #8] - TenForums

Here are some PowerShell guides -
I believe that, if you are going to invest your time & energy, studying PowerShell will earn you a much better return than studying batch files.
PowerShell Scripting - The Basics - TenForumsTutorials
PowerShell Scripting - Run a Script from Shortcut - TenForumsTutorials
PowerShell commands index - SS64
PowerShell forum - SS64
PowerShell Tutorials - Windows10Forums [2017] - I am normally wary of this website for reasons that I cannot remember [lots of content copied from TenForums possibly?] but their PS tutorial seems OK.
PowerShell Commands - ScriptRunner

All the best,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 21H2 Build 22000.978

The-Hive

The First Three Star Guru
Guru
VIP
Thread Starter
Local time
3:35 AM
Posts
11,293
Location
Wiltshire UK
OS
Windows 11 Pro
@Try3 thanks so much Denis so much to keep me going (y)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Alienware Area 51m R2
    CPU
    10th Gen Core i9 10900K
    Memory
    32GB
    Graphics Card(s)
    Geforce RTX 2080 Super
    Sound Card
    Nvidia HD
    Screen Resolution
    1920x1080
    Hard Drives
    C: Samsung 2TB P981A
    D: Samsung 2TB 970 Evo
    Case
    Dark side of the moon
    Mouse
    Alienware AW610M
    Browser
    Chrome and Firefox
    Antivirus
    Norton
    Other Info
    Killer E3000 Ethernet Controller
    Killer AX1650i Wi-Fi Network Adaptor
    Alienware Z01G Graphic Amplifier
    Tobii Eye Tracker
  • Operating System
    Dual Boot Windows 11 Pro / Windows 11 Pro Dev build
    Computer type
    Laptop
    Manufacturer/Model
    Dell Inspiron 3501
    CPU
    11th Gen i-7 2.80 gb
    Memory
    16Gb
    Screen Resolution
    1920 x 1080
    Hard Drives
    512Gb SSD
    WD 2GB EXT
    Browser
    Chrome
    Antivirus
    Norton

FreeBooter

Well-known member
Power User
VIP
Local time
5:35 AM
Posts
991
Location
Adana
OS
Windows 11

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

Latest Tutorials

Top Bottom