All skills
github avatar

/batch-files

@7b9e822 official
by githubgithub/awesome-copilot40k stars
5,040

Expert-level Windows batch file (.bat/.cmd) skill for writing, debugging, and maintaining CMD scripts. Use when asked to "create a batch file", "write a .bat script", "automate a Windows task", "CMD scripting", "batch automation", "scheduled task script", "Windows shell script", or when working with .bat/.cmd files in the workspace. Covers cmd.exe syntax, environment variables, control flow, string processing, error handling, and integration with system tools.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/batch-files

This session only. Nothing lands on disk.

referencescygwin.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Cygwin Reference

Cygwin provides a large collection of GNU and Open Source tools that provide functionality similar to a Linux distribution on Windows, plus a POSIX API DLL (cygwin1.dll) for substantial Linux API compatibility.

Documentation

User's Guide — Table of Contents

Chapter 1: Cygwin Overview

  • What is it? — POSIX compatibility layer and GNU toolset for Windows
  • Quick Start Guide (Windows users) — Getting started for those familiar with Windows
  • Quick Start Guide (UNIX users) — Getting started for those familiar with UNIX/Linux
  • Are the Cygwin tools free software? — Licensing (GPL/LGPL)
  • A brief history of the Cygwin project — Origins and evolution
  • Highlights of Cygwin Functionality
    • Permissions and Security
    • File Access
    • Text Mode vs. Binary Mode
    • ANSI C Library
    • Process Creation
    • Signals
    • Sockets and Select
  • What's new and what changed — Release notes for all versions (1.7.x through 3.6)

Chapter 2: Setting Up Cygwin

  • Internet Setup — Installing via setup-x86_64.exe, mirror selection, package management
  • Environment Variables — Configuring PATH, HOME, CYGWIN and other environment variables
  • Changing Cygwin's Maximum Memory — Adjusting memory limits via the registry
  • Internationalization — Locale and character set configuration
  • Customizing bash — .bashrc, .bash_profile, and prompt customization

Chapter 3: Using Cygwin

  • Mapping path names — How Cygwin maps POSIX paths to Windows paths (/cygdrive/c = C:\)
  • Text and Binary modes — Line ending handling (\n vs \r\n), mount options
  • File permissions — POSIX permission model on NTFS, ACLs
  • Special filenames — Device files, /proc, /dev, socket files
  • POSIX accounts, permission, and security — User/group mapping, passwd/group files, ntsec
  • Cygserver — Background service for shared memory, message queues, semaphores
  • Cygwin Utilities — Built-in command-line tools:
    • cygcheck — System information and package diagnostics
    • cygpath — Convert between POSIX and Windows paths
    • cygstart — Open files/URLs with associated Windows applications
    • dumper — Create Windows minidumps
    • getconf — Query POSIX system configuration
    • getfacl / setfacl — Get/set file access control lists
    • ldd — List shared library dependencies
    • locale — Display locale information
    • minidumper — Write a minidump of a running process
    • mkgroup / mkpasswd — Generate group/passwd entries from Windows accounts
    • mount / umount — Manage Cygwin mount table
    • passwd — Change passwords
    • pldd — List loaded DLLs for a process
    • profiler — Profile Cygwin programs
    • ps — List running processes
    • regtool — Access the Windows registry from the shell
    • setmetamode — Control meta key behavior in the console
    • ssp — Single-step profiler
    • strace — Trace system calls and signals
    • tzset — Print POSIX-compatible timezone string
  • Case-sensitive directories — Enabling per-directory case sensitivity on Windows 10+
  • Using Cygwin effectively with Windows — Integration tips, running Windows programs from Cygwin

Chapter 4: Programming with Cygwin

  • Using GCC with Cygwin — Compiling C/C++ programs with the Cygwin GCC toolchain
  • Debugging Cygwin Programs — Using GDB and other debugging tools
  • Building and Using DLLs — Creating shared libraries under Cygwin
  • Defining Windows Resources — Resource files and windres
  • Profiling Cygwin Programs — Performance profiling with gprof and ssp

Key Concepts for Batch Scripting

Invoking Cygwin from Batch Files

REM Run a Cygwin command from a batch file
C:\cygwin64\bin\bash.exe -l -c "ls -la /home"

REM Convert a Windows path to POSIX for Cygwin
C:\cygwin64\bin\cygpath.exe -u "C:\Users\John Doe\Documents"

REM Convert a POSIX path back to Windows
C:\cygwin64\bin\cygpath.exe -w "/home/jdoe/project"

Common Environment Variables

Variable Purpose
CYGWIN Runtime options (e.g., nodosfilewarning, winsymlinks:nativestrict)
HOME User home directory
PATH Must include /usr/local/bin:/usr/bin for Cygwin tools
SHELL Default shell (typically /bin/bash)
TERM Terminal type for console applications

Source: SKILL.md on GitHub

No alerts15d3 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill is a comprehensive reference guide and template collection for Windows batch scripting. It provides detailed documentation on command-line syntax, system administration tasks, and security best practices for preventing code injection in batch files. No malicious patterns or security risks were detected.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

Signed by skilld at 7b9e822. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 19 hours ago.

Activeupdated 5 months ago
  • batch
  • windows
  • cmd
  • shell-scripting
  • automation
  • scheduled-tasks
  • cli-tools
  • system-administration
  • error-handling
  • file-operations

README badge

README badge for github/awesome-copilot/batch-files

Writes, debugs, and maintains Windows batch files (.bat/.cmd) using cmd.exe syntax, control flow, error handling, and integration with system tools. Covers variable scoping, FOR loops, argument parsing, string manipulation, arithmetic, and file/network/system commands for CLI tool development, task automation, and scheduled scripts on Windows NT systems.

Generated from the current SKILL.md.

Does this skill cover PowerShell or only cmd.exe?
This skill is for cmd.exe batch files (.bat/.cmd) only. It does not cover PowerShell scripting.
Can I use this skill to write scripts for non-Windows systems?
No. This skill is Windows-specific and requires Windows NT-based OS (Windows 7 or later) with cmd.exe.
What should I use for string parsing and regex?
The skill covers FINDSTR (limited regex), substring syntax (%VAR:~start,length%), and FOR /F loops for parsing command output and files. Full regex support is not available in batch.
How do I handle errors in batch scripts?
Check %ERRORLEVEL% after commands, use && and || for conditional execution, or combine error checks with compound commands and parenthesized blocks.
Can I create reusable functions in batch files?
Yes. Use CALL :label to invoke functions, SETLOCAL/ENDLOCAL for variable scoping, and the endlocal & set pattern to return values from scoped blocks.

Generated from the current SKILL.md. These answers refresh after source changes.