Archive for the ‘VBScript’ Category

Run DOS command in VBscript

vbscript_icon
DOS command can be run in Vb Script using the Shell object The below script runs a mkdir command through Vb Script Set objShell = CreateObject(“WScript.Shell”) objShell.Run “%comspec% /c mkdir dir1″

Delete a Windows Service

It is rare to have to manually remove a Windows service but on there are times when it is necasarry, like after a bad uninstall or testing beta software. I personally use 1 of 2 methods to remove a service. Prior to removing any service make sure that it is atleast stopped and better yet disabled. Also make a note on the executable path so that it may be removed after the service is deleted. First Method: Open command prompt and use the “sc” command. in this case we want to delete a...

VBscript – Create Folders from Excel

1234567891011121314151617181920212223242526272829303132'======================================================== ' ' NAME: FolderFromExcel.vbs ' ' COMMENT:  Script will read Excel file.  Column A should contain '                  folder names. Folders will then be created. ' '======================================================== Dim objExcel, strPathExcel,strCN Dim objFile, intRow Set objFSO = CreateObject("Scripting.FileSystemObject") Set...

VBScript – Enumerates all SamAccounts in you current Domain

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112'========================================================================== ' NAME: List_AD_SamAccounts.vbs ' ' COMMENT: Enumerates all SamAccounts with department and descriptions ' '========================================================================== Option Explicit...

Add non-exchange address to Exchange 2007 Transport Rule via adsiedit

Exchange 2007 transport rules are very useful in most cases but I had issues once trying to set up a rule for emails sent from a APC battery unit to be forwarded to my cell phone via text message. But I would recieve an error when configuring the rule when attempting to add my cell number to as “CC” to the header. I ended up just editing the active directory configuration using adsiedit. To do this I first created a transport rule as I normally would but instead of attempting to change...

Runs a script against multiple computers

This snippet runs a script against multiple computers taken from a text file. A big time saver. 123456789101112131415161718192021'Create a FileSystemObject Set oFS = CreateObject("Scripting.FileSystemObject") 'Open a text file of computer names 'with one computer name per line Set oTS = oFS.OpenTextFile("c:computers.txt") 'go through the text file Do Until oTS.AtEndOfStream 'get the next computer name 'store it in variable sComputer sComputer = oTS.ReadLine '----------------------------------- '...

Script to check for new users or computers and email output

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165'========================================================================== ' ' ' NAME: ADAddedUsersNComputers.vbs ' '...

Run a command via vbscript

123456789101112131415161718192021222324252627'========================================================================== ' ' NAME: runcommand.vbs ' ' AUTHOR: John Sorensen ' ' COMMENT: ' '========================================================================== strCommand = "ipconfig" 'This is where you place command WScript.Echo "Running command: " & strCommand WScript.Echo set objShell = CreateObject("Wscript.Shell") set objProc  = objShell.Exec(strCommand) Do  ...

Password Generator VBScript

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194;'[]}{\|~`: '   The numbers...

Folder Report VbScript

1234567891011121314151617181920212223242526272829303132333435363738394041424344'************************************************************ ' File:  FolderReport.vbs ' '************************************************************ strSource="c:\" iGrandTotalCount=0 iGrandTotalSum=0 Set objFSO=CreateObject("Scripting.FileSystemObject") Set objFolder=objFSO.GetFolder(strSource) Call ProcessFiles(objFolder) WScript.Echo "Total count = "...
Twitter Delicious Facebook Digg Stumbleupon Favorites More
323 queries in 4.438 seconds.