Script file types

4.8 Explain the basics of scripting.

📘CompTIA A+ Core 2 (220-1202)


A script is a file containing a series of commands that a computer can execute automatically. Scripts are widely used in IT to automate tasks, manage systems, or run programs without having to do everything manually. Different scripting languages use different file extensions.

Here are the most common script file types you need to know for the exam:


1. .bat (Batch File)

  • What it is: A batch file is a script for Windows that contains a series of commands that run one after another in the Command Prompt.
  • File extension: .bat or sometimes .cmd
  • How it’s used in IT:
    • Automating repetitive tasks like deleting temporary files.
    • Running multiple commands at once, e.g., mapping network drives for multiple users.
  • Example commands inside a .bat file:
    • dir – lists files in a folder
    • copy – copies files from one folder to another
    • echo – displays a message

Key point: Batch files are easy to write but mainly work on Windows systems.


2. .ps1 (PowerShell Script)

  • What it is: A PowerShell script is used on Windows systems for more advanced tasks than batch files. It can work with files, users, and system settings.
  • File extension: .ps1
  • How it’s used in IT:
    • Automating system administration tasks like creating new user accounts in Active Directory.
    • Managing Windows updates or system configurations.
  • Why it’s important: PowerShell scripts are powerful because they can interact with almost every part of a Windows system.

Key point: Always run with proper permissions because .ps1 scripts can make major changes to the system.


3. .vbs (VBScript File)

  • What it is: VBScript (Visual Basic Script) is a Windows scripting language. It is often used for automating tasks in Microsoft applications like Excel or for administrative tasks.
  • File extension: .vbs
  • How it’s used in IT:
    • Automating Excel reports or reading data from files.
    • Displaying messages or alerts to users automatically.
  • Example command inside a .vbs file:
    • MsgBox "Backup complete!" – pops up a message box

Key point: VBScript is older but still used in some Windows environments.


4. .sh (Shell Script)

  • What it is: A shell script is a script for Linux/Unix systems that runs in a shell like Bash.
  • File extension: .sh
  • How it’s used in IT:
    • Automating server tasks, like starting/stopping services.
    • Running maintenance scripts on Linux servers.
  • Example commands inside a .sh file:
    • ls – lists files in a directory
    • cp file1.txt file2.txt – copies a file
    • echo "Task complete" – displays a message

Key point: Shell scripts are essential for Linux/Unix administration and are executed in a terminal.


5. .js (JavaScript File)

  • What it is: JavaScript is primarily a web scripting language used to make websites interactive.
  • File extension: .js
  • How it’s used in IT:
    • Adding interactivity to websites, like forms and animations.
    • Running scripts on the server side using Node.js (server-side JavaScript).
  • Example commands inside a .js file:
    • console.log("System check complete"); – logs messages for IT monitoring

Key point: JavaScript is widely used for web development, but can also be used for backend tasks with Node.js.


6. .py (Python File)

  • What it is: Python is a high-level scripting language used for automation, data analysis, and general programming.
  • File extension: .py
  • How it’s used in IT:
    • Writing scripts to automate tasks across multiple systems (e.g., moving files or monitoring system health).
    • Parsing logs, processing data, or managing cloud resources.
  • Example commands inside a .py file:
    • print("Backup finished") – prints a message
    • import os – allows file and system management

Key point: Python is extremely versatile and works on Windows, Linux, and macOS.


Summary Table of Script File Types

File TypePlatformPurpose/Use in ITNotes
.batWindowsAutomate command-line tasksSimple, basic automation
.ps1WindowsAdvanced admin automationRequires PowerShell
.vbsWindowsMicrosoft app automation, messagesOlder, limited now
.shLinux/UnixServer and system automationRun in terminal/shell
.jsAny (Web/Server)Website interactivity, Node.js scriptsMostly web-based
.pyCross-platformAutomation, data processing, general scriptsVery versatile

Exam Tip: For the CompTIA A+ exam, you should know the common file extensions, the platform they run on, and the basic use case for each. You don’t need to write complex scripts, just understand what each type does.

Buy Me a Coffee