Table of Contents
Code Snippets
Threading
Skip all sorts of Safe Threading calls
Threading a Sub with Params!
System Timer (threading them)
Wait for Threads to finish*
Cycle through a List(of threads) to abort and remove from list
Update control via Delegate Invoke
Picturebox with color and width Example
Tooltip Invoke
Drive Map and UnMap
Text Output Functions (Colorizing for Console)
Convert to RGB
Hex to Color
Text Output (spacing)
Create Text as an Image on the fly and add to control
New Way
Old way
ToIcon function icon
Display and render an SVG file
SQL - sGrabBetween (proc) (SubString)
SQL - sGrabBetween (function) (SubString)
Split String into n- number of characters per line
A Program is trying to Send an email on your Behalf
Outlook Version Reference
VBS - subSendEMail
PowerShell FTP and Send-ToEmail
VB.NET - Send Email
With expanded TO: lines
Restart Explorer Gracefully
Close a File Explorer window
Create SecureString
Grab Between in String
Grab Between in String (C#)
Remove Special Chars from String (Example)
Find a string by using a Predicate (ie for String(Of) )
Read File Contents (Text) at once
Class clsClearHistories
Read an Event Viewer Key that is not the traditional, but in the Windows structure
Example of Working with the Event Logs
Read HKCU for info
Read Registry Keys
Quck Read of Registry (One liner)
Convert SID to User (sAMAccountName)
Convert User (sAMaccountName) to SID
CopyKey and RecurseCopyKey Registry Key copies
Focus on Textbox
Running program in Explorer (detect)
Command Line Arguments
Get Environment Variable easy
my.resources write file
Quit if already running
Console Cancel Key Press (CONTROL+C/Break)
Unix Times (From, To, and Epoch)
WriteFile
Revision 2
Query Logged on users on a Server (query logon /server:..)
Uptime with PerformanceCounters
Valid_Ping
Is Port Open?
IP Check RegEx (VBscript)
IsDayTime Check time between two dates
Delay between then and now Pause if you will
Remove List View items more completely
Get ContextMenu's Listview
Remove HTML characters from string
IsFileOpen
Get the first/latest file in a patter from a folder/directory
Recursive Get all files in Folder structure
Restart AppPool
Active Directory - AD Group member Add/Remove, Other useful snippets for AD
FindFocusedControl
SetADProperty
IsInGroup
FindEntry
FindEntries
DeleteUserFromGroup
AddUserToGroup
btnAddGroups_Click
GetUserGroups
RecursiveGetGroups
RemoveMemberToGroup
Authenticate to AD and check Group Membership
Combobox convenience
FillComboBox
Sub SaveEntry(text As String) If My.Computer.FileSystem.DirectoryExists(Environment.GetEnvironmentVariable("APPDATA") & "\ChadRocks") Then Else My.Computer.FileSystem.CreateDirectory(Environment.GetEnvironmentVariable("APPDATA") & "\ChadRocks") End If txtFilter.Items.Add(text) End Sub SaveComboBox
Fill Combobox fast with a Adapter fill
GetCNfromsAMAccountName
GetDomainLessUsername
GetsUsernameFRomCN
Another way To add and remove AD groups. A simpler approach
Active Directory AD authentication in Classic ASP
Password Dialog box sample
KeyboardHook.vb
Example Form Call/setup/usage for the KeyboardHook.vb
Random Number Function in Range
Disk Info
Uptime for a server
Example of File Version comparison
Screen and Mouse Movement Mods
Impersonation
Run Remote Process (VBNet + WMI)
Start a process and wait for completion with time out
Make a form the TopLevel
Load a Font for the User Session from a Resource
Press Control key with a letter
Creating a MS-like fillable search bar
Using a Custom Caption
Custom Icons for a custom caption
Custom web page and how to do mouse over
Flash Icon in Tray
MSSQL Database INSERT, DELETE, and SELECT
MSSQL Insert type Image to field
MultipleActiveResultSets=true
ASP Get Image File from DB and Display in Browser
ASP Get Image HTML from DB and display in Browser
Classic ASP repost Form data
Import binary file into a sql varbinary(max) column (VBScript)
Execute Stored Procedure in VBNet
MySql Database INSERT, DELETE, SELECT, REPLACE
INSERT Example (paramaterized)
SELECT example
DELETE and REPLACE INTO example
TestSQL (MySql)
Parameter '@variable' must be defined
Services - Get State
Stop
Start
Getting Service Start type
Passing arguments to a Windows Service
Get Service ImagePath and/or Display Name
Outlook Automation of PSTs and Stores
Outlook VSTO
Ribbon Type (for creating a button in my case)
Put the Group and buttons on the HOME tab
Start a Process
One Off Process
Controlled Process
Button click to manipulate current/active email
Ribbon Button click to manipulate current/active email
MailItem Events with Listeners
Sorting Outlook Emails into Subfolders
Send a fax (example of manipulating To line)
Example of going through all Recipients in ItemSend() method
Center for to Screen or Parent Window
Screen
Parent Window
Covert Spreadsheet (xls) to CSV at command line
MS Access on Task Scheduler
RDS Get Users (non RDP users)
Remove Domain Name (NetBIOS) dynamically
Ini File Manipulation
Classic ASP Show all form Items and Keys
Edit Cells in ListView
Add combobox to listview
Change Color of ListView cell (ListItem)
Change Textbox to ComboBox with F3
Convert xls to csv in VBscript
Convert Day differences to decimal
JavaScript isValidDate (not exactly)
JavaScript isDate (between 1900-2100)
Close browser IE window when launching Chrome
reCatcha - HTML example
reCapthca - <BUTTON> validation Example
reCaptcha and RDGateway
WebFormSubmitter Class
WebFormSubmitter Example
jQuery require another field if radio button is clicked
VBS AD Accounts Expire
ipsec example block ports
Is IP Internal (VB.Net)
Is IP
Is IP Internal (C#)
event log watcher
Folder/File watcher...Open File watcher
Printing in VB.Net
Working with CSV/Tab characters
Turn off X, Min and Max in Console windows
Close Console Window (ie run in Forms mode)
Test if a user is in a group by using a SQL Stored Procedure
[master].[dbo].[GetLdapUserGroups]
pdfinfo to get Page Count
Count Characters Function
Test Toast
A Nicer Toast when Balloons dont't work
Tooltip on a label (control)
Turn off Tabs in TabControl
Launching an App as a user account (context) from a Service
Adding in Command Line Args
Check to see if a Process is running
Example
List Processes For a Session ID
Kill Remote Process
Read Outlook Calendar with Outlook Redemption.dll
This does not close COM object and fails
Read Outlook Categories (colors) from calendar
Read and process emails from Inbox
Encrypt and Decrypt text
Ribbon Fun
Make a particular Tab the Active Tab
Handling a RibbonTab change
Adding an entry to a Ribbon Drop down on the fly
Populating a Ribbon Drop down
Dynamic Ribbon Tab - Form Closing
Copy tab page
Copy List View items
Drag and Drop (VBNet)
Get the file icon and display in Listview
Get Username for a process
Allow a Service to run as a Console program
(In your main loop, not in OnStart(args), put this to keep it running)
Helpful: UserInteractive
Get JSON object
Get specific JSON stanzas for entries and return a Dictionary
Example, even with a JSON array
HTTPSession (web, produce file)
Instanstiate and Run it
isDirty handler VBnet Control changed save
Dynamic Controls (on same thread)
Add Resources to List
Timer example to update images
Get Resource ID Example (dynamically)
Garbage Collection
Rounded Corner Panel
MS Access Remove DBO prefix when import from ODBC
Linux Stuff
.screenrc
.bashrc (addition)
Find most recent modified files
Trim whitespace from BASH variable
How to remove all whitespace (denoted by [:space:] in tr):
How to remove leading whitespace only:
How to remove trailing whitespace only:
How to remove both leading and trailing spaces--chain the seds:
MSDOS
Init for CMD
Get Newest File from Command Line
Backup Profile Script for redundancy