Access denied error when resizing a HTA

When I resized a HTA with the following code:

 Sub Window_onLoad
     window.resizeTo 500,200
End Sub

I came across the following error:

Access Denied
Code: 0
Do you want to continue running scripts on this page?

This was due to a timing issue when loading the file. The Window_onLoad tries to change a property of the HTA, while the HTA is not completely loaded yet. You can solve this problem by adding a short timeout like this:

Sub Window_onLoad
Window.SetTimeout "Window.ResizeTo 500, 200", 500
End Sub

The last "500" here is the time it waits before executing the code.

Image of the error message:

VB Script that changes the CDROM drive letter

'
'    Script creates a local file that gets called by Diskpart to change the CDROM drive to Z:
'
'    

Read more: VB Script that changes the CDROM drive letter

Bubble Sort in VBS

This is the code required to sort an array in alphabetical order (you need UCase to convert the lower case to upper case, because VB sorts on ASCII value and the value of upper case characters is higher than that of lower case characters.

For i = (UBound(arrNames) - 1) to 0 Step -1
For j= 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
strHolder = arrNames(j+1)
arrNames(j+1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next

Bubble sort is not the most efficient way for sorting and should not be used on large arrays.

For more information on bubble sort: http://en.wikipedia.org/wiki/Bubble_sort

VB Script that creates shortcuts on remote machines

'
'
'This script creates a drive mapping to C$ of a list of servers, checks if a certain file exists and creates a
'shortcut in the startup menu to that file, then removes the mapping.
'
'
'

Read more: VB Script that creates shortcuts on remote machines