Skip to content

Instantly share code, notes, and snippets.

View atao's full-sized avatar
🇲🇫

ATAO atao

🇲🇫
  • Share-Link (FR)
View GitHub Profile
@atao
atao / lock_input.ps1
Last active January 15, 2025 15:11
⌨️ Lock keyboard and mouse during n seconds.
#Run As Administrator
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$code = @"
[DllImport("user32.dll")]
public static extern bool BlockInput(bool fBlockIt);
"@
$userInput = Add-Type -MemberDefinition $code -Name UserInput -Namespace UserInput -PassThru
@atao
atao / eject.ps1
Created July 3, 2017 22:26
Just eject CD drives!
function Eject-CD
{
$drives = Get-WmiObject Win32_Volume -Filter "DriveType=5"
if ($drives -eq $null)
{
Write-Warning "Your computer has no CD drives to eject."
return
}
$drives | ForEach-Object {
(New-Object -ComObject Shell.Application).Namespace(17).ParseName($_.Name).InvokeVerb("Eject")
@atao
atao / ducky.vbs
Created July 3, 2017 22:28
Test script to emulate keyboard...
'https://msdn.microsoft.com/en-us/library/office/aa202943%28v=office.10%29.aspx'
Set objShell = CreateObject("WScript.Shell")
WScript.Sleep 800
objShell.SendKeys "^{ESC}"
WScript.Sleep 800
objShell.SendKeys "cmd"
'objShell.SendKeys "^+{ENTER}"
'objShell.SendKeys "{LEFT}"
WScript.Sleep 800
objShell.SendKeys "{ENTER}"
@atao
atao / Wallpaper.ps1
Created July 7, 2017 12:34
Change wallpaper
# http://www.ghislain-lerda.com/2016/10/07/change-wallpaper/
$wallpaperPath = "mon_image.png"
$setwallpapersource = @"
using System.Runtime.InteropServices;
public class wallpaper
{
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
@atao
atao / encrypt-decrypt.ps1
Created July 11, 2017 11:58
Functions to crypt and decrypt string
# http://community.idera.com/powershell/powertips/b/tips/posts/encrypting-text-information-using-passphrase
function encrypt{
param(
[string]$pass,
[string]$text
)
$key = [Byte[]]($pass.PadRight(24).Substring(0,24).ToCharArray())
# $secure = $text | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString -Key $key
$secure = $text |
ConvertTo-SecureString -AsPlainText -Force |
@atao
atao / DL.ps1
Last active July 17, 2017 15:14
Vidéo Download from website using YouTube-dl
# Vidéo Download from website using YouTube-dl
# Version 17/07/2017
$data = Invoke-WebRequest "https://www.tf1.fr/tf1/c-est-canteloup"
# Get links
$data = $data.links | select href
# Remove Warning for exe
$env:SEE_MASK_NOZONECHECKS = 1
foreach ($line in $data){
if ($line.href -like "https://www.tf1.fr/tf1/c-est-canteloup/videos/*")
@atao
atao / Screenshot.ps1
Created July 18, 2017 09:03
Screenshot function
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
$date = Get-Date -Format yyyyMMddHHmmss
$File = "C:\Temp\Shot-$date.bmp"
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
@atao
atao / netsh.bat
Created July 18, 2017 09:42
How manage wireless networks with netsh?
REM Info for an interface
Netsh WLAN show interfaces
Netsh WLAN show interface name="Interface_Name"
REM Export Wireless key
Netsh WLAN export profile key=clear folder="c:\Temp"
REM Import profile
Netsh WLAN add profile filename="File_Path.XML"
@atao
atao / create_zip.ps1
Created August 23, 2017 14:10
Create zip from powershell
function copy-ToZip($fileSaveDir){
$srcdir = $fileSaveDir
$zipFile = "$env:localappdata\tmp\Report.zip"
if(-not (test-path($zipFile)))
{set-content $zipFile ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18));(dir $zipFile).IsReadOnly = $false}
$shellApplication = new-object -com shell.application;$zipPackage = $shellApplication.NameSpace($zipFile)
$files = Get-ChildItem -Path $srcdir
foreach($file in $files){$zipPackage.CopyHere($file.FullName);while($zipPackage.Items().Item($file.name) -eq $null){Start-sleep -seconds 1 }}
}
$fileSaveDir = 'C:\Users\USER\AppData\Local\tmp\blabla'
@atao
atao / backup-ansible.sh
Created April 10, 2018 10:37
Backup Ansible
#!/bin/bash
###########################################
# Backup Ansible
###########################################
# auteur : atao
VERSION="2018.04.10"
# Source : https://github.com/blogmotion/bm-RaspberryPi/blob/master/Backup%20scripts/backupToNas.sh
# Source : https://tecadmin.net/mysql-database-backup-to-ftp-server-shell-script/
# licence type : Creative Commons Attribution-NoDerivatives 4.0 (International)
# licence info : http://creativecommons.org/licenses/by-nd/4.0/