Skip to content

Instantly share code, notes, and snippets.

@rma92
rma92 / purge_storage_server_2016.cmd
Created July 18, 2018 21:01
Remove unnecessary features of Windows Storage Server 2016 (updated Jan 2018) for workstation use
REM install_wim_tweaker.exe: https://fdossena.com/?p=w10debotnet/index_1703.frag
REM Remove the crappy crap for great justice
Dism /online /Disable-Feature /FeatureName:Windows-Defender /Remove /NoRestart
Dism /online /Disable-Feature /FeatureName:Windows-Defender-Features /Remove /NoRestart
sc delete Diagnosticshub.standardcollector.service
sc delete dmwappushservice
sc delete wersvc
sc delete cdpusersvc
sc delete onesyncsvc
sc delete messagingsvc
@rma92
rma92 / runkey.c
Created September 12, 2018 18:26
C code for a program that registers Win+R, and dynamically loads Shell32.dll,#61 to invoke hotkey.
#include <windows.h>
#define VK_R 0x52
#define S_desc L"Type the name of a document, folder, program, or Internet resource, and Windows will open it for you."
#define S_t L"Run..."
#define S_dir L"%SYSTEMROOT%"
#define S_mt "Message"
#define S_no61 "Failed to load #61 (loaded Shell32.dll okay). Exiting"
#define S_noS "Failed to load Shell32.dll."
#define S_sR "Registered Win+R"
#define S_noR "Failed to register Win+R"
@rma92
rma92 / gist:4cb2273322cdae4d87bd8cc680b0dc14
Created September 19, 2018 18:51
Windows 7 Embedded Configurations for Generic Applications
Basic workstation programs:
This works for most everything.
Application Compatibility template
Modify Features
Remove:
Diagnostics\Problem Reports and Solutions
Fonts\[asian fonts]
International (everything)
IIS (if desired)
Management\Parental Control
@rma92
rma92 / beer.c
Last active November 26, 2018 21:23
Python: Asynchronous read subprocess stdout (*nix)
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for( i = 99; i; --i)
{
printf("%d bottles of beer on the wall, %d bottles of beer, take one down, pass it around, %d bottles of beer on the wall.\n", i, i, i-1);
fflush(stdout);
function Show-HTML ([string]$HTML)
{
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PowerShell HTML GUI" WindowStartupLocation="CenterScreen">
<WebBrowser Name="WebBrowser"></WebBrowser>
</Window>
@rma92
rma92 / lab1.ps1
Last active December 26, 2018 20:40
Powershell Script and Answer File to produce a Windows Server 2016 lab in Hyper-V, initially developed for testing different SCOM configurations.
#build the scom lab.
#Expectations: baseServer2016Lab.vhdx is a syspreped Server 2016 disk image.
#The vms go on a private network, called "SCOM-Test"
#Router with DHCP server is available, 192.168.1.0/24 with 192.168.1.1 as the gateway
#DHCP should send DNS servers as 192.168.1.2 or something else.
#I'm using a dns suffix
$transcript_path = "log{0}.log" -f (Get-Date -UFormat %s -Millisecond 0)
Start-Transcript -Path $transcript_path
@rma92
rma92 / bbx.vim
Created February 25, 2019 21:54
VIM colors
" Vim color file BBx, based on torte.
" Maintainer: Ricahrd Marino
" Last Change: 2019 Feb 22
" amber on black
" optimized for TFT panels
" based on default torte theme.
set background=dark
hi clear
if exists("syntax_on")
@rma92
rma92 / uac_test.c
Created March 18, 2019 19:12
Demonstrates checking if running as administrator and UAC elevation. Only depends on user32 and kernel32, dynamically loads advapi32 for token check and shell32 for shellexecute. Unicode.
#ifndef UNICODE
#define UNICODE
#define _UNICODE
#endif
#include <windows.h>
//cl.exe -nologo -Gm- -GR- -EHa- -GS- -Oi -Tc uac_test.c -link -nodefaultlib -subsystem:windows user32.lib kernel32.lib
//Shell32: dynamic load for ShellExecuteW
//AdvApi32: dynamic load for AllocateAndInitializeSid, CheckTokenMembership, and FreeSid.
//NTDLL: dynamic load to abuse it's internal C runtime functions (swprintf_s). This makes the executable teeny.
//See: https://www.codeproject.com/Articles/320748/Haephrati-Elevating-during-runtime
@rma92
rma92 / exec_adm.c
Created March 20, 2019 02:04
Run <command line> as admin on Windows.
//Execute as admin
//cl.exe -nologo -Gm- -GR- -EHa- -GS- -Oi -Tc exec_adm.c -link -nodefaultlib /ENTRY:_start -subsystem:windows kernel32.lib
//tcc exec_adm.c -nostdlib -lkernel32
#include <windows.h>
void _start()
{
wchar_t* cp = GetCommandLineW();
wchar_t* pp; //Parameters
@rma92
rma92 / readme.txt
Last active July 23, 2019 00:35
UniFi Controller on Windows Embedded Standard
This is pretty easy to get working, and has a pretty low footprint, especially on x86.
-Windows Embedded Standard 7, use the Industrial Automation template. I removed the .net Frameworks, IIS, and added Diagnostics\User to get Task Manager. I also added the file compression utility. Disk footprint was 910 MB.
Note: if you are using a network share to install you may need to start the Computer Browser service.
-Install Java. Correct Bitness for the system installed.
-Install UniFi controller.
-Follow these instructions to install UniFi as a service: https://help.ubnt.com/hc/en-us/articles/205144550-UniFi-Run-the-Controller-as-a-Windows-Service
-At this point, the disk space used was 1.63GB.
Optinally, compress the disk.