Skip to content

Instantly share code, notes, and snippets.

@simply-coded
simply-coded / MsgStack.vbs
Last active October 3, 2022 19:42
Create multiple msgbox popups without waiting for a return value to continue.
Option Explicit
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim wsh : Set wsh = CreateObject("Wscript.Shell")
Dim args : Set args = WScript.Arguments
Dim this : this = WScript.ScriptFullName
Dim id, ans
'create message boxes
If args.count = 0 Then
@simply-coded
simply-coded / BrowseForFolder.vbs
Created August 6, 2017 01:55
Browse for folder dialog box in VBScript.
Function BrowseForFolder()
'@description: Browse for folder dialog.
'@author: Jeremy England (SimplyCoded)
Dim oFolder
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0,"Select a Folder",0,0)
If (oFolder Is Nothing) Then
BrowseForFolder = Empty
Else
BrowseForFolder = oFolder.Self.Path
End If
@simply-coded
simply-coded / QuickZip.vbs
Last active October 7, 2021 02:36
Compress and decompress zip files in VBScript.
Function QuickZip(path)
'@description: Compress and uncompress zip files.
'@author: Jeremy England (SimplyCoded)
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oSap : Set oSap = CreateObject("Shell.Application")
Dim oWss : Set oWss = CreateObject("WScript.Shell")
Dim isZip, count, root, base, add, out
Dim isZipping, isCancelable
Const NOT_FOUND = 1
Const NOT_A_ZIP = 2
@simply-coded
simply-coded / AlwaysOnTop.vbs
Last active May 31, 2021 12:33
Makes a window always on top if setOnTop is true, else makes it normal again. Will wait up to 10 seconds for window to load.
Sub AlwaysOnTop(appName, regExpTitle, setOnTop)
' @description: Makes a window always on top if setOnTop is true, else makes it normal again. Will wait up to 10 seconds for window to load.
' @author: Jeremy England (SimplyCoded)
If (setOnTop) Then setOnTop = "-1" Else setOnTop = "-2"
CreateObject("wscript.shell").Run "powershell -Command """ & _
"$Code = Add-Type -MemberDefinition '" & vbcrlf & _
" [DllImport(\""user32.dll\"")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags);" & vbcrlf & _
" [DllImport(\""user32.dll\"")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);" & vbcrlf & _
" public static void AlwaysOnTop (IntPtr fHandle, int insertAfter) {" & vbcrlf & _
" if (insertAfter == -1) { ShowWindow(fHandle, 7); ShowWindow(fHandle, 9); }" & vbcrlf & _
@simply-coded
simply-coded / RunAsAdminNoUAC.md
Last active January 6, 2021 16:07
Will run the current VBScript as an administrator without a UAC prompt after the initial setup run.
@simply-coded
simply-coded / BrowseForFile.md
Last active September 5, 2020 14:27
Browse for file dialog box in VBScript.
@simply-coded
simply-coded / carousel.md
Last active September 5, 2020 14:22
A JavaScript object that creates a simple carousel out of any element with the class "carousel".
@simply-coded
simply-coded / Console.md
Last active September 5, 2020 14:17
Run command prompt command and get its output in VBScript.
@simply-coded
simply-coded / ShowWindow.md
Last active September 5, 2020 14:13
AppActivate alternative that works even if the window is minimized in VBScript.
@simply-coded
simply-coded / FormatString.md
Last active September 5, 2020 14:09
VBScript Class to evaluate data in strings between {curly brackets} or user defined tokens. The class also allows for easy appending of strings.