🠪  General

  🠪  Servers
  🠪  Testing
  🠪  Tips

  🠪  3D Printing
  🠪  Apple
  🠪  Batteries
  🠪  Drives
  🠪  Edgerouter
  🠪  Electronics
  🠪  Laptop
  🠪  Modems
  🠪  Phone
  🠪  Printers
  🠪  Raspberry Pi
  🠪  Tablets
  🠪  Testing
  🠪  Virtualization

  🠪  General

  🠪  Interesting
  🠪  Media

  🠪  Data
  🠪  Testing
  🠪  VPN

  🠪  Batch
  🠪  Linux
  🠪  Powershell

  🠪  Databases
  🠪  Misc
  🠪  Website

  🠪  Other

  🠪  Backup
  🠪  Fix Issues
  🠪  Recovery

  🠪  Editing

  🠪  HTML
  🠪  Testing

  🠪  Adjustments
  🠪  Issues
  🠪  Remote Desktop
  🠪  Security
  🠪  Slow
  🠪  Software
  🠪  Startup

Submit Entry
Airin's Notes

Category: Scripts 🠪 Batch
Backup File - Template
November 28, 2023

@echo off
for /f %%i in ('powershell ^(get-date^).DayOfWeek') do set dow=%%i
echo %dow%
rem The above now has the day like "Tuesday" or "Friday" set as an environment variable

robocopy /mir /r:0 /DCOPY:T /xj c:\ "h:\Backups\Daily\%dow%"

Category: Scripts 🠪 Batch
Convert media file using ffmpeg
November 30, 2023

Put the following in a batch file. You will need to download ffmpeg and place it in some path.

--------------- Start --------------
@echo off
set ffmpeg="C:\Tools\Utils\ffmpeg-win-2.2.2\ffmpeg.exe"
set infolder=C:\Temp\In-WAV
set outfolder=C:\Temp\Out-MP3
set infiletype=wav
set outfiletype=mp3

echo Starting!
echo Input folder: %infolder%
echo Output folder: %outfolder%
echo Input filetype: %infiletype%
echo Output filetype: %outfiletype%

cd...<Too long, click to read the rest>

Category: Scripts 🠪 Batch
Cycle Network adapter to make the link light flash
November 30, 2023

@echo off
set message=Press C to cancel this script.
set delay=10
set interface=Ethernet
set /a count = 0
echo Starting disabling of '%interface%'interface. It will be disabled every %delay% seconds.
set /a count += 1
echo Disabling Ethernet... Loop #%count%
netsh interface set interface "%interface%" disabled
CHOICE /C CL /M "%message%" /D L /T %delay% /N
if '%ERRORLEVEL%'=='1' goto done
echo Enabling Ethernet... Loop #%count%
netsh interface set interface "%interface%" en...<Too long, click to read the rest>

Category: Scripts 🠪 Batch
Handbrake Batch File to convert passed folders/files
November 27, 2023

@echo off

REM Loop through each argument (dragged item)
if "%~1"=="" goto end

REM Create a directory for the current item
mkdir "D:\video\temp\%~n1"

FOR /F "tokens=*" %%G IN ('DIR "%~1" /B /S /A:-d') do (
FOR /F "tokens=*" %%H IN ('DIR "%%G" /B /A:-d') do (
"C:\Program Files\Handbrake\HandBrakeCLI" -i "%%G" --optimize -o "D:\video\temp\%~n1\%%~nH.mp4" -e nvenc_h265 -q 26 --cfr --aencoder av_aac --verbose=1

REM Shift arguments to process the next item
...<Too long, click to read the rest>

Category: Scripts 🠪 Batch
ICACLS - Windows File Permissions
February 11, 2024

/t - Recursive
/C - Continue after errors are found

Add user as Owner of a folder
icacls.exe d:\test /setowner domain\username /t /C

Add user/group with Full permissions to a folder:
icacls "C:\Folder" /grant Users:(OI)(CI)F /t /C

Another thing to try (taken from askvg link below):
takeown /f foldername /r /d y
icacls foldername /grant administrators:F /t
icacls "C:\FolderName" /grant Administrators:(OI)(CI)F /t /C

Regedit to add an option to File Explorer:
https://www.askvg...<Too long, click to read the rest>

Category: Scripts 🠪 Batch
nslookup Syntax
November 30, 2023

Look up standard A DNS records for a domain:

Look up a TXT DNS record:
nslookup -q=TXT

Look up an A DNS record, test a specific DNS server to see what it says

Category: Scripts 🠪 Batch
Remove empty folders from a path
November 26, 2023

robocopy "c:\path\to\directory" "c:\path\to\directory" /S /move

Category: Scripts 🠪 Batch
November 27, 2023

This page explains options quite well:

Copy folder modified date

Copy in Backup mode, which copies all files, and bypasses many permission issues

Backup Onedrive quickly
robocopy /mir /xj /w:0 /r:0 "C:\Users\user\OneDrive" "Z:\OnedriveBackup\Onedrive" /copyall /LOG:C:\Users\user\onedrive.txt /mt

Move files from one folder to another. This basically just moves all files from source to destination, ...<Too long, click to read the rest>

Category: Scripts 🠪 Batch
Run command for each commandline argument passed
November 30, 2023

%%x will effectively equal %1, then %2, etc.

for %%x in (%*) do (
powershell.exe -File "%ps1path%" -File "%%x"

Category: Scripts 🠪 Batch
ShadowSpawn allows VSS enabled Robocopy
December 2, 2023

ShadowSpawn is a utility that allows you to create a VSS snapshot and then run a backup from it (to copy locked files). It unmounts the VSS snapshot when the command is finished.

Basic usage of ShadowSpawn.exe
ShadowSpawn.exe C:\Data K: robocopy k:\ "\\server01\Backup\Data" /B /MIR /xj /r:0

Keywords: VSS, Volume Shadow Copy, Backup, Locked Files

Category: Scripts 🠪 Batch
November 30, 2023

Lots of Date Batch File examples are on this page:
More pages are available too:

rem Set the date in the format "2020-10-24" to the variable %Today%
FOR %%A IN (%Date%) DO (
FOR /F "tokens=1-3 delims=/-" %%B in ("%%~A") DO (
SET Today=%%D-%%B-%%C
echo Date to use for filenames: '%Today%'

Category: Scripts 🠪 Batch
Upload file via FTP
December 1, 2023

Put the FTP command script in a .txt file, then make a shortcut or batch file containing:
ftp.exe -s:C:\Temp\testftp.txt

Below is the script to put in a text file:
---------------------- Start ----------------------
cd ""
lcd "C:\Temp\Uploads"
put 1.mp3
--------------------- End -----------------------

Category: Scripts 🠪 Batch
VSS - Volume Shadow Copies
December 1, 2023
Mount shadow volumes on disk images

select vdisk file=C:\myimage.vhd
attach vdisk readonly

vssadmin list shadows
vssadmin list shadows /for=E:\
vssadmin list
mklink /D C:\shadow_volume_1 \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy7\
rd C:\shadow_volume_1

Configure VSS on Windows Server<Too long, click to read the rest>

This site is meant to be used as a reference for myself, although others may find it useful. I use it to keep track of certain fixes, software, and other solutions which I may need while assisting customers. The page layout is pure HTML/CSS and is kept simple to optimize loading time and fast results.

Return to Airin's Computers