Windows Scripts
Windows Scripts
Steps to Create and Run the Batch Script:
1. Create the Batch Script :-
- Open Notepad or any text editor.
- Copy and paste the script above.
- Save the file with a `.bat` extension, e.g., `config_laptops.bat`.
2. Run the Batch Script as Administrator :
- Right-click the saved `.bat` file.
- Select "Run as administrator".
This should allow you to set the password without encountering issues when logging in.
Batch File Scripts:-
For Batch Printing :-
@ECHO OFF
NET USE LPT1: /DELETE
NET USE LPT1: \\CP-PC\GENERIC /PERSISTENT:YES
Batch File SQl Database Auto Backup :-@echo off
echo "TAKING BACKUPS.....PLEASE WAIT....."
F:
cd \@ AGI DATABASE BACKUP
SET "NAME=%DATE:/=%"
ECHO "CREATING A FOLDER FOR THE DATE.....PLEASE WAIT....."
MKDIR %NAME%
CD %NAME%
ECHO "STOPPING DATABASE ENGINE.....PLEASE WAIT....."
NET STOP MSSQLSERVER
ECHO "COPYING DATA FILES.....PLEASE WAIT....."
COPY "D:\Data\TTS32Server_DATA.MDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\TTS32Server_LOG.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
ECHO "RESTARTING DATABASE ENGINE.....PLEASE WAIT....."
timeout /T 10 /NOBREAK
NET START MSSQLSERVER
PAUSE
EXIT
Batch Code for SQl Database Backup :-
@echo off
echo "TAKING BACKUPS.....PLEASE WAIT....."
F:
cd \@ AGI DATABASE BACKUP
SET "NAME=%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%"
ECHO "CREATING A FOLDER FOR THE DATE.....PLEASE WAIT....."
MKDIR %NAME%
CD %NAME%
ECHO "STOPPING DATABASE ENGINE.....PLEASE WAIT....."
NET STOP MSSQLSERVER
ECHO "COPYING DATA FILES.....PLEASE WAIT....."
COPY "D:\Data\TTS32Server_DATA.MDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\TTS32Server_LOG.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\CESServer_Data.MDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\CESServer_Log.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\GeneralDB_Data.MDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "D:\Data\GeneralDB_Log.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbedpol.mdf" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbedpol_log.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ReportServer.mdf" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ReportServer_log.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ReportServerTempDB.mdf" "F:\@ AGI DATABASE BACKUP\%NAME%\"
COPY "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\ReportServerTempDB_log.LDF" "F:\@ AGI DATABASE BACKUP\%NAME%\"
ECHO "RESTARTING DATABASE ENGINE.....PLEASE WAIT....."
timeout /T 10 /NOBREAK
NET START MSSQLSERVER
PAUSE
EXIT
Batch Code to Copy Network Shared File:=
@echo off
echo "TAKING BACKUPS.....PLEASE WAIT....."
SET "SOURCE_DIR=E:\TESTING\ARE"
SET "DEST_DIR=\\ops-1-pc\D\Branch Backup\Testing"
echo "CREATING A FOLDER FOR THE DATE.....PLEASE WAIT....."
SET "NAME=%DATE:/=%"
MKDIR "%DEST_DIR%\%NAME%"
pushd "%DEST_DIR%\%NAME%"
echo "STOPPING DATABASE ENGINE....PLEASE WAIT....."
NET STOP MSSQLSERVER
echo "COPYING DATA FILES. PLEASE WAIT....."
COPY "%SOURCE_DIR%\TTS32db_Data.MDF" .
COPY "%SOURCE_DIR%\TTS32db_Log.LDF" .
echo "RESTARTING DATABASE ENGINE....PLEASE WAIT....."
timeout /T 10/NOBREAK
NET START MSSQLSERVER
PAUSE
EXIT
Local Software Installation Script ( Power Shell) :-
# Ask for confirmation
Write-Host "This script will temporarily set the execution policy and run the install_softwares.ps1 script."
$confirm = Read-Host "Do you want to continue? (Y/N)"
if ($confirm -eq "Y" -or $confirm -eq "y") {
# Set execution policy for the current session to Bypass
Set-ExecutionPolicy -Scope Process Bypass
# Define the path to the software directory
$softwarePath = "F:\Softwares"
# List of software executables to install
$softwareList = @(
@{Name = "7z1514-x64.exe"; Path = "$softwarePath\7z1514-x64.exe"
@{Name = "AnyDesk.msi"; Path = "$softwarePath\AnyDesk.msi"},
@{Name = "Firefox Setup 109.0.1.msi"; Path = "$softwarePath\Firefox Setup 109.0.1.msi"},
@{Name = "
@{Name = "npp.8.5.2.Installer.x64.exe"; Path = "$softwarePath\npp.8.5.2.
@{Name = "OcsAgentSetup.exe"; Path = "$softwarePath\OCSNG_WINDOWS_
@{Name = "nsepa64.msi"; Path = "$softwarePath\CitrixVPN-MSI-
@{Name = "AGEE_setup.exe"; Path = "$softwarePath\CitrixVPN-MSI-
@{Name = "EPPClientSetup_6.2.2.1006_
@{Name = "Zscaler-windows-4.2.0.217-
@{Name = "SentinelOneInstaller_windows_
)
# Install each software with special handling
foreach ($software in $softwareList) {
Write-Host "Installing $software.Name interactively..."
Start-Process -FilePath $software.Path -Wait
Write-Host "$software.Name installation completed."
}
} else {
Write-Host "Operation canceled by user."
}
Network Path Software Installation (Power Shell ) Script :-
# Ask for confirmation
Write-Host "This script will temporarily set the execution policy and run the install_softwares.ps1 script."
$confirm = Read-Host "Do you want to continue? (Y/N)"
if ($confirm -eq "Y" -or $confirm -eq "y") {
# Set execution policy for the current session to Bypass
Set-ExecutionPolicy -Scope Process Bypass
# Define the network shared folder path
$softwarePath = "\\ictteam-dt\Mallesh-DT\Basic softwares"
# List of software executables to install
$softwareList = @(
@{Name = "7z1514-x64.exe"; Path = "$softwarePath\7 zip\64 bit\7z1514-x64.exe"},
@{Name = "AnyDesk.msi"; Path = "$softwarePath\AnyDesk.msi"},
@{Name = "Firefox Setup 109.0.1.msi"; Path = "$softwarePath\Firefox Setup 109.0.1.msi"},
@{Name = "GoogleChromeStandaloneEnterprise64.msi"; Path = "$softwarePath\GoogleChromeStandaloneEnterprise64.msi"},
@{Name = "npp.8.6.7.Installer.x64.exe"; Path = "$softwarePath\npp.8.6.7.Installer.x64.exe"},
@{Name = "OcsAgentSetup.exe"; Path = "$softwarePath\OCSNG_WINDOWS_AGENT_1.02\OcsAgentSetup.exe"},
@{Name = "AGEE_setup.exe"; Path = "$softwarePath\Citrix VPN\CitrixVPN-MSI-64bit\AGEE_setup.exe"},
@{Name = "nsepa64.msi"; Path = "$softwarePath\Citrix VPN\CitrixVPN-MSI-64bit\nsepa64.msi"},
@{Name = "EPPClientSetup.6.2.2.1006_x86_64_[a=pluto.india.tejasnetworks.com] (1).msi"; Path = "$softwarePath\New version DLP\EPPClientSetup.6.2.2.1006_x86_64_[a=pluto.india.tejasnetworks.com] (1).msi"},
@{Name = "Zscaler-windows-4.2.0.217-installer-x64.msi"; Path = "$softwarePath\Zscaler-windows-4.2.0.217-installer-x64.msi"},
@{Name = "SentinelOneInstaller_windows_64bit_v23_4_4_223.exe"; Path = "$softwarePath\SentinelOneInstaller_windows_64bit_v23_4_4_223\SentinelOneInstaller_windows_64bit_v23_4_4_223.exe"}
)
# Install each software with special handling
foreach ($software in $softwareList) {
Write-Host "Installing $($software.Path) interactively.."
Start-Process -FilePath $software.Path -Wait -WorkingDirectory $softwarePath # Added WorkingDirectory parameter
Write-Host "Installation of $($software['Name']) completed."
}
} else {
Write-Host "Operation canceled by user."
}
Network Path Software Installation (Power Shell ) Script with Admin Credential Prompt :-
# Ask for confirmation
Write-Host "This script will temporarily set the execution policy and run the install_softwares.ps1 script."
$confirm = Read-Host "Do you want to continue? (Y/N)"
if ($confirm -eq "Y" -or $confirm -eq "y") {
# Set execution policy for the current session to Bypass
Set-ExecutionPolicy -Scope Process Bypass -Force
# Define the network shared folder path
$networkPath = "\\invardc1\IT\Santhosh.b\@basic-varite"
# Prompt for username and password
$username = Read-Host "Enter your network username (e.g., domain\username)"
$password = Read-Host "Enter your network password" -AsSecureString
# Convert secure password to plain text for authentication (PowerShell requires this for net use)
$passwordPlain = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(
[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)
)
# Authenticate with the network share
net use $networkPath /user:$username $passwordPlain 2>$null # Suppress errors if already connected
# Clear password from memory for security
$passwordPlain = $null
# Check if the path is accessible
if (!(Test-Path $networkPath)) {
Write-Host "Error: Unable to access network path. Check credentials."
exit
}
# List of software executables to install
$softwareList = @(
@{Name = "Anydesk"; Path = "$networkPath\AnyDesk.exe"},
@{Name = "Mozilla Firefox"; Path = "$networkPath\Firefox Installer.exe"},
@{Name = "Multi Presenter"; Path = "$networkPath\MultiPresenter_Win_Installer_v1_2_2.exe"},
@{Name = "GoogleChrome"; Path = "$networkPath\ChromeSetup.exe"},
@{Name = "RADMIN Server"; Path = "$networkPath\Radmin_Server_3.5.2.1_EN.msi"},
@{Name = "Sophos"; Path = "$networkPath\SophosSetup-Sandhya.exe"},
@{Name = "VITEL GLOBAL"; Path = "$networkPath\VITELGLOBALAPP-5.6.0.0~57ea533bfd-x64-.exe"},
@{Name = "Microsoft Office 365"; Path = "$networkPath\OfficeSetup 64.exe"},
@{Name = "Grammarly"; Path = "$networkPath\GrammarlyAddInSetup.exe"}
)
# Install each software
foreach ($software in $softwareList) {
if (Test-Path $software.Path) {
Write-Host "Installing $($software.Name) interactively..."
Start-Process -FilePath $software.Path -Wait
Write-Host "Installation of $($software.Name) completed."
} else {
Write-Host "Warning: $($software.Name) not found at $($software.Path)"
}
}
# Disconnect from the network share
net use $networkPath /delete /y
} else {
Write-Host "Operation canceled by user."
}
Power Shell Script for Installing MS Office through Network Path :-
{Note :-" Set-ExecutionPolicy -Scope Process Bypass " for executing the script }
{ To Revert Execution Policy :- "Set-ExecutionPolicy -Scope Process Default" }
# Ask for confirmation
Write-Host "This script will temporarily set the execution policy and run the install_softwares.ps1 script."
$confirm = Read-Host "Do you want to continue? (Y/N)"
if ($confirm -eq "Y" -or $confirm -eq "y") {
# Set execution policy for the current session to Bypass
Set-ExecutionPolicy -Scope Process Bypass
# Define the network shared folder path
$softwarePath = "\\ictteam-dt\Mallesh-DT\Basic softwares\MS-Office 2021\MS-Office 2021"
# List of software to install with necessary information
$softwareList = @(
@{
Name = "MS Office 2021"
SetupFile = "setup.exe"
Arguments = "/configure configuration.xml"
WorkingDirectory = "$softwarePath"
}
)
# Install each software with error handling
foreach ($software in $softwareList) {
Write-Host "Installing $($software.Name)..."
try {
Start-Process -FilePath "$($softwarePath)\$($software.SetupFile)" -ArgumentList $software.Arguments -WorkingDirectory $software.WorkingDirectory -Wait
Write-Host "Installation of $($software.Name) completed successfully."
} catch [System.Exception] {
Write-Host "Error installing $($software.Name): $($_.Exception.Message)"
}
}
} else {
Write-Host "Operation canceled by user."
}
Change the Command Prompt window to run as an administrator using a command.
Here's how to do it:
Open Command Prompt: Search for "cmd" in the Start menu and open it normally.
Use the
runascommand: Type the following command and press Enter:runas /user:Administrator "cmd"Replace "Administrator" with the actual administrator username if it's different.
Enter the administrator password: You'll be prompted to enter the password for the administrator account.
Once you enter the correct password, a new Command Prompt window will open with administrator privileges. You can then use the usual commands to perform administrative tasks.
Dell Software Installation Batch FIle :-
@echo off
cls
color 4f
@echo.
@echo ############################################################################
@echo #
@echo # There are total Three Sections in Install Citrix VPN and Notepad++
@echo #
@echo # Wait to start using the system until the last script run
@echo # Wait for the Message POST INSTALLATION PROCESS COMPLETED
@echo #
@echo # System Will Auto Reboot Post Green Screen
@echo #
@echo # System Will Auto Reboot Post Green Screen
@echo #
@echo #############################################################################
@echo off
echo -- INSTALLATION PROCESS Begins Now --
echo -- INSTALLATION PROCESS Begins Now --
echo -- INSTALLATION PROCESS Begins Now --
echo -- Script will Auto start after 5 Seconds --
timeout /t 05
echo -- Section one --
echo -- CitrixVPN-AGEE_setup Install in progress --
start /wait CMD.EXE /C C:\source\AGEE_setup\agee64.msi /quiet /norestart
echo -- Script will Auto start after 05 Seconds --
timeout /t 05
echo -- CitrixVPN-nsepa_setup Install in progress --
start /wait CMD.EXE /C C:\source\nsepa_setup\nsepa64.msi /quiet /norestart
echo -- Script will Auto start after 05 Seconds --
timeout /t 05
echo -- npp.8.5.2.Installer.x64 Install in progress --
start /wait CMD.EXE /C C:\source\npp.8.5.2.Installer.x64.exe /S
echo -- Script will Auto start after 05 Seconds --
timeout /t 05
cls
@color 2F
@echo.
@echo ####################################################
@echo #
@echo # POST INSTALLATION PROCESS COMPLETED
@echo # POST INSTALLATION PROCESS COMPLETED
@echo # POST INSTALLATION PROCESS COMPLETED
@echo #
@echo # System Will Auto Reboot
@echo # System Will Auto Reboot
@echo # System Will Auto Reboot
@echo # System Will Auto Reboot
@echo ####################################################
timeout /t 10
shutdown -r -t 0
Password Lock a FOLDER Windows:- ( Folder Lock )
@ECHO OFF
cls
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder? (Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Private "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked successfully
goto END
:UNLOCK
echo Enter password to unlock folder:
set/p "pass=>"
if NOT %pass%==YourPasswordHere goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder unlocked successfully
goto END
:FAIL
echo Invalid password
goto END
:MDLOCKER
md Private
echo Folder created successfully
goto END
:END
pause
Here's how to use this script:
- Open Notepad and copy-paste the code above
- Replace "YourPasswordHere" with your desired password
- Save the file with a .bat extension (e.g., "locker.bat") in the same location as your "Private" folder
- Double-click the batch file to run it
When you run the script:
- If the folder is unlocked, it will ask if you want to lock it
- If the folder is locked, it will ask for the password to unlock it
- If the Private folder doesn't exist, it will create one
Comments
Post a Comment