banner



How To Run A Script Windows

Windows 10 create batch file
Windows 10 create batch file (Image credit: Windows Central)

On Windows x, a batch file typically has a ".bat" extension, and information technology is a special text file that includes one or multiple commands that run in sequence to perform various actions with Command Prompt.

Although yous tin blazon commands manually to execute a detail task or modify system settings on Windows 10, a batch file simplifies the work of having to re-type the commands, saving you time and avoiding mistakes.

You lot can besides utilize other tools similar PowerShell to write fifty-fifty more advanced scripts. Yet, running batch files in Command Prompt is still relevant to execute commands to change settings, automate routines, and launch apps or web pages on your device.

In this Windows ten guide, we will walk you through the steps to create and run a batch file. Also, we will outline the steps to create advanced scripts and rum them automatically on schedule using the Task Scheduler.

  • How to create a batch file on Windows ten
  • How to run a batch file on Windows 10

How to create a batch file on Windows x

The process of writing a batch file is straightforward. You only need Notepad or some other text editor and some basic knowledge typing commands in Command Prompt. These instructions will help you lot create a basic and advanced batch file to query arrangement settings.

Create basic Windows 10 batch file

To create a basic batch file on Windows x, employ these steps:

  1. Open Commencement.
  2. Search for Notepad and click the top result to open the text editor.
  3. Type the following lines in the text file to create a batch file:@ECHO OFFECHO Hello World! Your beginning batch file was printed on the screen successfully.PauseThe to a higher place script outputs the phrase, "Hello World! Your showtime batch file was printed on the screen successfully," on the screen.
    • @Echo OFF — Shows the message on a clean line disabling the display prompt. Unremarkably, this line goes at the commencement of the file. (You can use the command without the "@" symbol, but it's recommended to include it to show a cleaner return.)
    • Echo — The control prints the text later the space on the screen.
    • PAUSE — Allows the window to stay open after the command has been executed. Otherwise, the window will close automatically every bit soon as the script finishes executing. You lot can use this command at the end of the script or after a specific command when running multiple tasks and desire to break between each line.

Source: Windows Central (Prototype credit: Source: Windows Central)

Source: Windows Central (Paradigm credit: Source: Windows Fundamental)
  1. Click the File menu.
  2. Select the Save every bit option.
  3. Ostend a name for the script — for instance, first_basic_batch.bat.Quick note: While batch files typically apply the .bat file extensions, you tin also find them using the .cmd or .btm file extensions.

One time yous complete the steps, double-click the file to run it. Alternatively, you tin can use the steps below to learn the unlike means you can run a batch file with Command Prompt, File Explorer, or Task Scheduler.

Create advanced Windows x batch file

To create an advanced Windows batch file with multiple commands, use these steps:

  1. Open Offset.
  2. Search for Notepad and click the top result to open the text editor.
  3. Type the following lines in the text file to create a more advanced Windows 10 batch file:@ECHO OFF :: This batch file details Windows 10, hardware, and networking configuration.Title My Organisation InfoECHO Delight expect... Checking system information.:: Section 1: Windows 10 informationECHO ==========================ECHO WINDOWS INFOECHO ============================systeminfo | findstr /c:"OS Name"systeminfo | findstr /c:"OS Version"systeminfo | findstr /c:"Organisation Type":: Section ii: Hardware information.ECHO ============================Echo HARDWARE INFOECHO ============================systeminfo | findstr /c:"Total Physical Memory"wmic cpu become namewmic diskdrive become name,model,sizewmic path win32_videocontroller get namewmic path win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution:: Section 3: Networking information.Echo ============================Echo NETWORK INFOECHO ============================ipconfig | findstr IPv4ipconfig | findstr IPv6START https://back up.microsoft.com/en-us/windows/windows-x-system-requirements-6d4e9a79-66bf-7950-467c-795cf0386715PAUSEThe above script runs each line to query a series of system details, and the issue will be divided into three categories, including "WINDOWS INFO," "HARDWARE INFO," and "NETWORK INFO." Also, the "START" command will open the web browser in the official support folio outlining the Windows ten system requirements, which you can cheque confronting your information.
    • @ECHO OFF — Shows the message on a clean line disabling the display prompt. Unremarkably, this line goes at the beginning of the file.
    • Title — Prints a custom name in the championship bar of the console window.
    • :: — Allows writing comments and documentation information. These details are ignored when the system runs the batch file.
    • Repeat — Prints the text subsequently the space on the screen.
    • START — Opens an app or website with the default web browser.
    • Interruption — Tells the console window to stay open after running the command. If you do not use this selection, the window volition close automatically as soon equally the script finishes executing.

Source: Windows Central (Epitome credit: Source: Windows Central)

Source: Windows Central (Paradigm credit: Source: Windows Central)
  1. Click the File menu.
  2. Select the Salvage as option.
  3. Type a name for the script — for case, first_advanced_batch.bat.

Later on you complete the steps, double-click the .bat file to run it or use the steps below to execute the script with Command Prompt, File Explorer, or Task Scheduler.

Create actionable Windows 10 batch file

You can also write batch scripts for any task that does not require user interaction. For instance, to map a network drive, install an application, change system settings, and more.

To create a non-interactive batch file on Windows ten, utilise these steps:

  1. Open up Commencement.
  2. Search for Notepad and click the top result to open the text editor.
  3. Blazon the following command to map a network drive in the text file:net use z: \\PATH-NETWORK-SHARE\FOLDER-NAME /user:YOUR-USERNAME YOUR-PasswordIn the command, supplant the \PATH-NETWORK-SHARE\FOLDER-NAME for the folder network path to mount on the device, and YOUR-USERNAME YOUR-PASSWORD with the username and password that authenticates admission to the network share.This example maps a network binder as a drive inside File Explorer using the "Z" drive letter:net employ z: \\x.1.4.174\ShareFiles Quick note: The screenshot includes the "pause" command, merely this is not required. It was added in this example to take a screenshot of the panel. If y'all are accessing the files from another calculator that uses a specific username and password, do not forget to use the /user: pick with the correct credentials.

Source: Windows Key (Image credit: Source: Windows Central)

Source: Windows Central (Paradigm credit: Source: Windows Central)
  1. Click the File menu.
  2. Select the Save as pick.
  3. Confirm a name for the script — for example, mount-z-network-drive.bat.

In one case you consummate the steps, the batch file will map the network folder without opening a Command Prompt window.

We just demonstrate a script with a single command, but you tin include as many equally you similar, as long equally you lot write them one per line.

How to run a batch file on Windows x

Windows 10 has at to the lowest degree three ways to write batch files. You can run them on-demand using Command Prompt or File Explorer. Using the Task Scheduler app, yous tin can configure the script to run it on schedule. Or you lot can save the batch files in the "Startup" folder to let the organisation run them equally shortly as you lot sign into the account.

Run batch file on-demand

If you want to run a script on-demand, you can use File Explorer or Command Prompt.

Command Prompt

To run a script file with Command Prompt on Windows 10, use these steps:

  1. Open First.
  2. Search for Command Prompt, right-click the elevation result, and select the Run equally administrator option.
  3. Type the following command to run a Windows 10 batch file and press Enter:C:\PATH\TO\FOLDER\BATCH-NAME.batIn the control, make sure to specify the path and name of the script.This case runs the batch file located in the "scripts" folder inside the "Downloads" folder:C:\Users\UserAccount\Downloads\first_basic_batch.bat

Source: Windows Key (Image credit: Source: Windows Central)

Later on y'all complete the steps, the console will return the results, and the window won't close even if the script does not include the "PAUSE" command since you are invoking the script from within a console session that was already open.

File Explorer

To run a batch file with File Explorer, utilise these steps:

  1. Open up File Explorer.
  2. Scan to the binder with the batch file.
  3. Double-click the script file to run information technology.
  4. (Optional) If a control in the batch file requires ambassador privileges, yous will take to run the script equally an admin by right-clicking the file and selecting the Run as administrator option.

Source: Windows Cardinal (Image credit: Source: Windows Key)
  1. Click the Yeah button

Once you complete the steps, the script will run each control in sequence, displaying the results in the panel window.

Run batch files on startup

Windows 10 as well features a known folder called "Startup," which the system checks every time it starts to run applications, shortcuts, and scripts automatically without the need for extra configuration.

To run a script on the Windows 10 startup, use these steps:

  1. Open up File Explorer.
  2. Open to the binder containing the batch file.
  3. Right-click the batch file and select the Copy option.
  4. Utilise the Windows key + R keyboard shortcut to open up the Run command.
  5. Type the post-obit command:shell:startup

Source: Windows Central (Image credit: Source: Windows Central)
  1. Click the OK push button.
  2. Click the Paste option from the "Home" tab in the Startup folder. (Or click the Paste shortcut button to create a shortcut to the batch file.)

Source: Windows Cardinal (Image credit: Source: Windows Central)

After you consummate the steps, the batch file volition execute automatically every time you log into your account.

Run batch file with Job Scheduler

To apply Chore Scheduler to run the batch file automatically at a specific fourth dimension, utilise these steps:

  1. Open up Start.
  2. Search for Task Scheduler and click the acme effect to open the app.
  3. Right-click the "Task Scheduler Library" branch and select the New Folder option.
  4. Confirm a name for the folder — for instance, MyScripts.Quick note: You lot don't need to create a binder, only keeping the organisation and your tasks split up is recommended.
  5. Click the OK button.
  6. Expand the "Job Scheduler Library" co-operative.
  7. Right-click the MyScripts folder.
  8. Select the Create Bones Task option.

Source: Windows Central (Image credit: Source: Windows Central)
  1. In the "Name" field, ostend a name for the chore — for example, SystemInfoBatch.
  2. (Optional) In the "Description" field, write a clarification for the task.
  3. Click the Adjacent button.
  4. Select the Monthly option.Quick note: Task Scheduler lets you choose from different triggers, including a specific date, during startup, or when a user logs in to the computer. In this example, we volition select the option to run a task every month, merely you may need to configure additional parameters depending on your selection.

Source: Windows Central (Prototype credit: Source: Windows Key)
  1. Click the Next push.
  2. Use the "Start" settings to confirm the twenty-four hour period and fourth dimension to run the chore.
  3. Use the "Monthly" drop-downwardly menu to pick the months of the twelvemonth to run the job.

Source: Windows Central (Image credit: Source: Windows Central)
  1. Use the "Days" or "On" drop-down carte du jour to confirm the days to run the task.

Source: Windows Fundamental (Paradigm credit: Source: Windows Central)
  1. Click the Next button.
  2. Select the Get-go a plan selection to run the batch file.

Source: Windows Central (Epitome credit: Source: Windows Fundamental)
  1. In the "Program/script" field, click the Browse push.
  2. Select the batch file you lot want to execute.

Source: Windows Cardinal (Image credit: Source: Windows Key)
  1. Click the Stop push.

Once you complete the steps, the job will run the script during the configured time and date or action.

The to a higher place instructions are meant to schedule only a basic chore. You lot can use these instructions to create a more customizable task with the Task Scheduler.

This guide focuses on Windows 10, but the same steps will as well piece of work for older versions, including Windows 8.1 and Windows vii. Also, y'all can refer to these instructions if you lot have Windows 11 installed on your figurer.

More Windows resources

For more helpful articles, coverage, and answers to common questions about Windows ten and Windows 11, visit the following resource:

  • Windows 11 on Windows Central — All yous need to know
  • Windows eleven help, tips, and tricks
  • Windows 10 on Windows Central — All yous demand to know

Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the near out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he's a recognized fellow member of the Microsoft MVP community.

Source: https://www.windowscentral.com/how-create-and-run-batch-file-windows-10

Posted by: florescuse1944.blogspot.com

0 Response to "How To Run A Script Windows"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel