Цитата yuv:
А как же тогда bat-ник выполняется? »
|
Вот Вы настырный, дружище
. Чёрта с два б я когда-нибудь к этому вернулся.
Пробуйте:
читать дальше »
Код:
Option Explicit
Dim objMenuItem
Dim strTempFileName
With WScript.CreateObject("WScript.Shell").Environment("Process")
.Item("DEVMGR_SHOW_NONPRESENT_DEVICES") = "1"
.Item("DEVMGR_SHOW_DETAILS") = "1"
End With
With WScript.CreateObject("MMC20.Application")
.Load "devmgmt.msc"
With .Document
With .ActiveView
.Frame.Maximize
For Each objMenuItem In .ScopeNodeContextMenu
If objMenuItem.Path = "Вид->Показать скрытые устройства" Then
If objMenuItem.Enabled = 1 Then
objMenuItem.Execute
Exit For
End If
End If
Next
End With
If .IsSaved = 0 Then
strTempFileName = GetTemporaryFileName()
.SaveAs strTempFileName
WScript.CreateObject("Scripting.FileSystemObject").DeleteFile strTempFileName, True
End If
End With
.UserControl = 1
End With
WScript.Quit 0
'=============================================================================
'=============================================================================
Function GetTemporaryFileName()
Const TEMP_FOLDER = 2
Dim strTempFile
With WScript.CreateObject("Scripting.FileSystemObject")
Do
strTempFile = .BuildPath(.GetSpecialFolder(TEMP_FOLDER), .GetTempName)
Loop While .FileExists(strTempFile)
End With
GetTemporaryFileName = strTempFile
End Function
'=============================================================================