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″
Archive for the ‘VBScript’ Category
Delete a Windows Service
Posted by John Sorensen on October 16th, 2009
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
Posted by John Sorensen on August 31st, 2009
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...
Add non-exchange address to Exchange 2007 Transport Rule via adsiedit
Posted by John Sorensen on August 19th, 2009
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
Posted by John Sorensen on June 29th, 2009
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
Posted by John Sorensen on June 29th, 2009
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165'==========================================================================
'
'
' NAME: ADAddedUsersNComputers.vbs
'
'...
Run a command via vbscript
Posted by John Sorensen on June 29th, 2009
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
Posted by John Sorensen on June 29th, 2009
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194;'[]}{\|~`:
' The numbers...
Folder Report VbScript
Posted by John Sorensen on June 29th, 2009
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 = "...


Posted in
Tags: