Removed hostname checking and fixed crash if connect to image share fails.
This commit is contained in:
parent
fc2dcc8fae
commit
4c40b79a99
1 changed files with 99 additions and 99 deletions
|
@ -12,47 +12,49 @@ Dim sDrive, sVmrunPath
|
||||||
sDrive = "\\st-vmware\vmware"
|
sDrive = "\\st-vmware\vmware"
|
||||||
sVmrunPath = sDrive & "\bin\vmrun.vbs"
|
sVmrunPath = sDrive & "\bin\vmrun.vbs"
|
||||||
|
|
||||||
If LCase(Left(oNetwork.ComputerName, 9)) = "stupid-pc" Or _
|
' Determine vmware icon path and quit if not found (eg. vmware not installed)
|
||||||
LCase(oNetwork.ComputerName) = "ee-pc2" Then
|
Dim sIconPath
|
||||||
|
On Error Resume Next
|
||||||
' Determine vmware icon path and quit if not found (eg. vmware not installed)
|
sIconPath = oShell.RegRead("HKCR\VMware.Document\DefaultIcon\")
|
||||||
Dim sIconPath
|
If Err.Number Then
|
||||||
On Error Resume Next
|
|
||||||
sIconPath = oShell.RegRead("HKCR\VMware.Document\DefaultIcon\")
|
|
||||||
If Err.Number Then
|
|
||||||
WScript.Quit
|
WScript.Quit
|
||||||
End If
|
End If
|
||||||
On Error Goto 0
|
On Error Goto 0
|
||||||
|
|
||||||
' Init regexps
|
' Init regexps
|
||||||
Dim oReConfig
|
Dim oReConfig
|
||||||
Set oReConfig = New RegExp
|
Set oReConfig = New RegExp
|
||||||
oReConfig.IgnoreCase = True
|
oReConfig.IgnoreCase = True
|
||||||
oReConfig.Pattern = "^\s*([a-z\.0-9]*)\s*=\s*""?([^""]+)""?$"
|
oReConfig.Pattern = "^\s*([a-z\.0-9]*)\s*=\s*""?([^""]+)""?$"
|
||||||
|
|
||||||
' Get path to users start menu
|
' Get path to users start menu
|
||||||
Dim sShortcutFolder
|
Dim sShortcutFolder
|
||||||
sShortcutFolder = oShell.SpecialFolders("StartMenu") & _
|
sShortcutFolder = oShell.SpecialFolders("StartMenu") & _
|
||||||
"\Programs\VMware Images"
|
"\Programs\VMware Images"
|
||||||
|
|
||||||
' Create shortcut directory if it doesn't exist
|
' Create shortcut directory if it doesn't exist
|
||||||
If Not oFS.FolderExists(sShortcutFolder) Then
|
If Not oFS.FolderExists(sShortcutFolder) Then
|
||||||
oFS.CreateFolder(sShortcutFolder)
|
oFS.CreateFolder(sShortcutFolder)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Remove old shortcuts
|
' Remove old shortcuts
|
||||||
Dim oFolder, oFile
|
Dim oFolder, oFile
|
||||||
Set oFolder = oFS.GetFolder(sShortcutFolder)
|
Set oFolder = oFS.GetFolder(sShortcutFolder)
|
||||||
For Each oFile In oFolder.Files
|
For Each oFile In oFolder.Files
|
||||||
If Right(Lcase(oFile.Name), 4) = ".lnk" Then
|
If Right(Lcase(oFile.Name), 4) = ".lnk" Then
|
||||||
oFS.DeleteFile(oFile.Path)
|
oFS.DeleteFile(oFile.Path)
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' Find image files and loop through them
|
' Find image files and loop through them
|
||||||
Dim oImageFolder, iTest
|
Dim oImageFolder, iTest
|
||||||
Set oImageFolder = oFS.GetFolder(sDrive & "\")
|
On Error Resume Next
|
||||||
For Each oFolder In oImageFolder.SubFolders
|
Set oImageFolder = oFS.GetFolder(sDrive & "\")
|
||||||
|
If Err.Number Then
|
||||||
|
WScript.Quit
|
||||||
|
End If
|
||||||
|
On Error Goto 0
|
||||||
|
For Each oFolder In oImageFolder.SubFolders
|
||||||
On Error Resume Next
|
On Error Resume Next
|
||||||
iTest = oFolder.Files.Count
|
iTest = oFolder.Files.Count
|
||||||
If Err.Number = 0 Then
|
If Err.Number = 0 Then
|
||||||
|
@ -96,13 +98,13 @@ If LCase(Left(oNetwork.ComputerName, 9)) = "stupid-pc" Or _
|
||||||
Else
|
Else
|
||||||
On Error Goto 0
|
On Error Goto 0
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' Fix vmware preferences.ini
|
' Fix vmware preferences.ini
|
||||||
Dim sPreferences
|
Dim sPreferences
|
||||||
sPreferences = oFS.BuildPath(oShell.ExpandEnvironmentStrings("%APPDATA%"), _
|
sPreferences = oFS.BuildPath(oShell.ExpandEnvironmentStrings("%APPDATA%"), _
|
||||||
"VMware\preferences.ini")
|
"VMware\preferences.ini")
|
||||||
If Not oFS.FileExists(sPreferences) Then
|
If Not oFS.FileExists(sPreferences) Then
|
||||||
If Not oFS.FolderExists(oFS.GetParentFolderName(sPreferences)) Then
|
If Not oFS.FolderExists(oFS.GetParentFolderName(sPreferences)) Then
|
||||||
oFS.CreateFolder(oFS.GetParentFolderName(sPreferences))
|
oFS.CreateFolder(oFS.GetParentFolderName(sPreferences))
|
||||||
End If
|
End If
|
||||||
|
@ -119,8 +121,6 @@ If LCase(Left(oNetwork.ComputerName, 9)) = "stupid-pc" Or _
|
||||||
oFile.WriteLine("pref.componentDownloadPermission = ""deny""")
|
oFile.WriteLine("pref.componentDownloadPermission = ""deny""")
|
||||||
oFile.Close
|
oFile.Close
|
||||||
Set oFile = Nothing
|
Set oFile = Nothing
|
||||||
End If
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Set oShell = Nothing
|
Set oShell = Nothing
|
||||||
|
|
Loading…
Add table
Reference in a new issue