Skip to content

Instantly share code, notes, and snippets.

@maciakl
maciakl / shadowcopy.cmd
Created July 1, 2022 04:34
Interactive helper script to create a shadowcopy job that will create a snapshot of your c: drive every day at 1pm.
@echo off
if "%1" == "elevated" goto start
powershell -command "Start-Process %~nx0 elevated -Verb runas"
goto :eof
:start
@echo off
cls
@maciakl
maciakl / admin.cmd
Created July 1, 2022 04:28
Interactive helper script to activate Admin account and change it's password
@echo off
if "%1" == "elevated" goto start
powershell -command "Start-Process %~nx0 elevated -Verb runas"
goto :eof
:start
@echo off
cls
@echo off
if "%1" == "elevated" goto start
powershell -command "Start-Process %~nx0 elevated -Verb runas"
goto :eof
:start
@echo off
cls
@maciakl
maciakl / .vimrc_minimal
Last active May 31, 2025 02:47
Minimal .vimrc for servers
nnoremap <space> <nop>
let mapleader="\<space>"
inoremap jj <esc>
noremap <C-l> [sz=
set number
set cursorline
set showmatch
set hlsearch
set incsearch
set spell
@maciakl
maciakl / debian_logo_motd.sh
Created June 26, 2022 17:34
A nice script generating a red Debian Spiral logo. Perfect for your MOTD.
#!/bin/bash
echo -e "\e[1;31m"
echo -e " _,edm\$\$\$\$\$on."
echo -e " ,d\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P."
echo -e " ,g\$\$P\"\" \"\"\"Y\$\$.\"."
echo -e " ,\$\$P' \`\$\$\$."
echo -e " ',\$\$P ,ggs. \`\$\$b:"
echo -e " \`d\$\$' ,\$P\"' . \$\$\$"
echo -e " \$\$P d\$' , \$\$P"
echo -e " \$\$: \$\$. - ,d\$\$'"
@maciakl
maciakl / cleanup.cmd
Created January 13, 2022 15:59
Script to clean up your Downloads directory by deleting all files and folders older than 14 days
@echo off
REM Remove files older than 14 days
forfiles /p "C:\Users\lmaciak\Downloads" /s /m *.* /c "cmd /c Del @path" /d -14
forfiles /p "C:\Users\lmaciak\Downloads" /s /d -14 /c "cmd /c if @isdir == TRUE RMDIR /S /Q @path"
@maciakl
maciakl / servicetag.cmd
Created January 13, 2022 15:56
Get the service tag (Dell) or vendor assigned serial number of your computer. This returns just the number, without other wmic output.
@echo off
for /f "skip=1" %%a in (
'wmic bios get serialnumber'
) do echo %%a & goto next
:next
@maciakl
maciakl / localip.cmd
Created January 13, 2022 15:55
Get you local ip address from the Windows command line
@echo off
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do set NetworkIP=%%a
echo %NetworkIP%
@maciakl
maciakl / whatismyip.cmd
Created January 13, 2022 15:54
Get your public/routable ip address from the windows command line
@echo off
for /f "tokens=1* delims=: " %%A in (
'nslookup myip.opendns.com. resolver1.opendns.com 2^>NUL^|find "Address:"'
) Do set ExtIP=%%B
echo %ExtIP%
@maciakl
maciakl / python_same_window_fix.cmd
Created January 10, 2022 21:27
This fixes the issue on Windows where running Python script directly by invoking its name (eg. script.py) on the command line, launches a new console window, instead of showitg the output in the same console.
rem Run CMD.EXE as Admin, then
assoc .py=Python.File
rem Assuming you installed Python via the Microsoft use below
rem If yuou installed Python via an installer, substitute the absolute path to the python executable
ftype Python.File=%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe "%1" %*