This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM:<RunAsAdmin> | |
' Place this code at the top of your VBScript file to run the script as an admin. | |
' It will quit the current script and re-run the script as an administrator. | |
' Note that depending on your UAC permissions you may be prompted. | |
' Does not support command line arguments. | |
If Not WScript.Arguments.Named.Exists("AsAdmin") Then | |
CreateObject("Shell.Application").ShellExecute "WScript.exe", """" & WScript.ScriptFullName & """ /AsAdmin", "", "runas", 1 | |
WScript.Quit | |
End If | |
REM:</RunAsAdmin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM:<RunAsAdminNoUAC> | |
' Place this code at the top of your VBScript file you'd like to run with admin permissions. | |
' When you first run it it will ask for UAC permissions and run and add a task to your Windows 'Task Scheduler' with the name of the script. | |
' From here on out the VBScript file name and location should not be changed. | |
' Next time you run it, it will be called from the Task Scheduler with admin permissions and thus not prompt for UAC anymore. | |
' This script runs with WScript.exe, and does not support command line arguments. | |
' To delete the task, use the Windows Task Scheduler. | |
With CreateObject("WScript.Shell") | |
If WScript.Arguments.Named.Exists("CreateTask") Then | |
.Run "schtasks /Create /SC ONCE /TN """ & WScript.ScriptName & """ /TR ""wscript.exe \""" & WScript.ScriptFullName & "\"" /AsAdmin"" /ST 00:01 /IT /F /RL HIGHEST", 0, True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Edit-Item { | |
<# | |
.SYNOPSIS | |
Sendkeys the contents of $Path into a here string in the current console for quick simple edits. Should not be used on large files. | |
.EXAMPLE | |
edit file.txt | |
#> | |
[CmdletBinding()] | |
param ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-Sql { | |
<# | |
.SYNOPSIS | |
Executes and returns the results of an SQL query. | |
.EXAMPLE | |
$results = Invoke-Sql -ConnectionString "Server=TEST-SERVER\SQLEXPRESS;Database=Test_DB;Integrated Security=True" -Query "SELECT * FROM Employee" | |
Calls an SQL query and saves the results. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Carousel(containerID) { | |
/* | |
@description: A pure javascript carousel. | |
@author: Jeremy England, http://codeartery.com/ | |
@mini: function Carousel(t){this.container=document.getElementById(t)||document.body,this.slides=this.container.querySelectorAll(".carousel"),this.last=this.slides.length-1,this.slide=0,this.next=function(){this.slide===this.last?this.slide=0:this.slide+=1,this.goto(this.slide)},this.prev=function(){0===this.slide?this.slide=this.last:this.slide-=1,this.goto(this.slide)},this.play=function(t,s){if(s?this.prev():this.next(),"number"==typeof t&&t%1==0){var i=this;this.run=setTimeout(function(){i.play(t,s)},t)}},this.stop=function(){clearTimeout(this.run)},this.goto=function(t){if(t>=0&&t<=this.last){this.stop();for(var s=0;s<=this.last;s++)this.slides[s].style.display=s===t?"inline-block":"none";return!0}return console.log("ERROR: Carousel.GoTo("+t+"): Index out of range 0.."+this.last),!1},this.goto(0)} | |
*/ | |
this.container = document.getElementById(containerID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function BrowseForFile() | |
REM@description | |
' HTML based browse for file dialog that doesn't require a temporary file. | |
REM@returns | |
' BrowseForFile <string> - The file path of the selected file. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini | |
' Function BrowseForFile():BrowseForFile=CreateObject("WScript.Shell").Exec("mshta.exe ""about:<input type=file id=f><script>resizeTo(0,0);f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(f.value);close();</script>""").StdOut.ReadLine():End Function | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IsProcessRunning( processNameExe ) | |
IsProcessRunning = GetObject("WinMgmts:\\.\root\cimv2") _ | |
.ExecQuery("SELECT * FROM Win32_Process WHERE Name LIKE '" & processNameExe & "'") _ | |
.Count > 0 | |
End Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function FormatDateAs( dInput, sFormat, padZero ) | |
REM@description | |
' Format a date based off of a user defined 'd', 'm', 'y' pattern. | |
REM@params | |
' dInput <date> - The date to format. | |
' sFormat <string> - The 'd', 'm', 'y' format you want the date in. | |
' padZero <bool> - Pads blank spaces with zeros when extra 'd', 'm', or, 'y's are provided than needed. | |
REM@returns | |
' FormatDateAs <string> - The formatted date. | |
REM@author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CmdOut( pCmd ) | |
REM@description | |
' Run a command prompt command and get its output. | |
REM@params | |
' pCmd <string> - A command prompt command. | |
REM@returns | |
' CmdOut <string> - The output of the command. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Import( vbsFile ) | |
REM@description | |
' Import/include/using code from an external VBScript file. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@params | |
' vbsFile <string> - A relative, absolute, or URL path to a file containing vbscript code. | |
REM@returns | |
' Import <bool> - Returns False if the import failed, and True if it succeeded. | |
REM@mini |
NewerOlder