Showing posts with label batch file. Show all posts
Showing posts with label batch file. Show all posts

Saturday, 21 August 2021

Copy folders and sub folders using batch file

Batch file can be used to automate copying files from one folder to another folder. We can use xcopy command to copy files and folder. For this demo I have created two folders with names Source and Destination. In source folder we have placed two files and one folder. We want to copy files and folder from Source folder to Destination folder.

Please follow below steps:-

1)Open notepad.

2)Type following code in notepad and save file with .bat extension.

@echo off

xcopy /i/s "D:\Source" "D:\Destination"

pause

3)Run the file by clicking on it.

We have used xcopy command to copy files from source folder to destination folder.

Syntax of command is like this:-

   xcopy /i/s "Source Folder Path" "Destination Folder Path"

          where /i - Displays a list of files that are to be copied.

                   /s  -Copies directories and subdirectories, unless they are empty. 


Copy folders and sub folders using batch file


    Watch my YouTube video on this topic:-


Saturday, 14 August 2021

How to reset IIS using batch file ?

 Please follow below steps to reset IIS using batch file :-

1) Open Notepad. Type command "C:\Windows\System32\iisreset.exe"

reset IIS using batch file

2)Save notepad file with .bat extension.

reset IIS using batch file

3)To reset  IIS, run .bat file as administrator.

reset IIS using batch file

   IIS reset shown in below image :-


So, in this way we can reset IIS using batch file. This batch file is very useful for automating IIS reset.


Tuesday, 10 August 2021

How to create batch file to start and stop service ?

 Please follow below steps:-

1)Open notepad.

2)To start service type net start <Service Name> and save file as start.bat

e.g  MSSQL$SQLEXPRESS service



3)To stop service type net stop <Service Name> and save file as stop.bat


4)To run service, right click on batch file and select run as administrator.

    Service Started using .bat file:-


    Service stopped using .bat file:-