|
|
Result = IsComExist( "Lbox.BatchHelper" )
if Result <> "" then
WScript.Echo Result
end if
' **********************************************************
' COM が登録されているかどうか
' **********************************************************
Function IsComExist( strProgID )
Dim strValue
on error resume next
strValue = WshShell.RegRead("HKCR\" & strProgID & "\CLSID\")
if Err.Number <> 0 then
IsComExist = ""
Exit Function
end if
strValue = "HKCR\CLSID\" & strValue
strValue = strValue & "\InprocServer32\"
strValue = WshShell.RegRead(strValue)
if Err.Number <> 0 then
IsComExist = ""
Exit Function
end if
strValue = WshShell.ExpandEnvironmentStrings( strValue )
on error goto 0
IsComExist = strValue
End Function
| |
|
|
|
|
WScript.Echo GetSystemDirectory( )
' **********************************************************
' システムディレクトリの取得
' **********************************************************
Function GetSystemDirectory( )
Dim obj
Set obj = CreateObject( "Shell.Application" )
Set objFolder = obj.Namespace( &H25 )
Set objFolderItem = objFolder.Self
GetSystemDirectory = objFolderItem.Path
End Function
| |
|
|
|
|
ErrMessage = "インストールに失敗しました。システム権限で実行して下さい"
EndMessage = "インストールが完了しました"
nNextStep = 1
' ----------------------------------------------------------
' COM
' ----------------------------------------------------------
strProg = "Lbox.dll"
nStep = 1
strTarget = IsComExist( "Lbox.BatchHelper" )
if strTarget = "" then
nNextStep = 6
end if
nStep = 3
if nStep >= nNextStep then
WScript.Echo strProg & _
" を既に登録されているパスで存在チェック"
if Fso.FileExists( strTarget ) then
nNextStep = 5
end if
end if
nStep = 4
if nStep >= nNextStep then
WScript.Echo strProg & _
" を登録されているパスへコピー (" & _
strTarget & ")"
Call Fso.CopyFile( strProg, strTarget )
end if
nStep = 5
if nStep >= nNextStep then
strCommand = "regsvr32.exe /u """ & strTarget & """"
WScript.Echo strProg & _
" が正しく登録されているのでいったん登録解除 (" & _
strCommand & ")"
' 実行終了を待つ
Call WshShell.Run( strCommand,,True )
end if
nStep = 6
if nStep >= nNextStep then
strTarget = GetSystemDirectory( )
WScript.Echo strProg & _
" をシステムディレクトリへコピー (" & _
strTarget & ")"
if strTarget = "" then
WScript.Echo ErrMessage
WScript.Quit
end if
Call Fso.CopyFile( strProg, strTarget & "\" & strProg )
end if
nStep = 7
if nStep >= nNextStep then
strCommand = "regsvr32.exe """ & strTarget & "\" & strProg & """"
WScript.Echo strProg & _
" をシステムディレクトリの登録ファイルで登録します (" & _
strCommand & ")"
' 実行終了を待つ
Call WshShell.Run( strCommand,,True )
end if
WScript.Echo EndMessage
| |
|
|
Windows Script Component の登録 |
|
|
' **********************************************************
' Windows Script Component が登録されているかどうか
' **********************************************************
Function IsWscExist( strProgID )
Dim strValue
on error resume next
strValue = WshShell.RegRead("HKCR\" & strProgID & "\CLSID\")
if Err.Number <> 0 then
IsWscExist = ""
Exit Function
end if
strValue = "HKCR\CLSID\" & strValue
strValue = strValue & "\ScriptletURL\"
strValue = WshShell.RegRead(strValue)
if Err.Number <> 0 then
IsWscExist = ""
Exit Function
end if
on error goto 0
IsWscExist = Right( strValue, Len( strValue ) - 7 )
End Function
| |
|
|
' ----------------------------------------------------------
' Windows Script Component
' ----------------------------------------------------------
strProg = "BatchWsc.wsc"
nStep = 8
strTarget = IsWscExist( "Lbox.BatchWsc" )
if strTarget = "" then
nNextStep = 12
end if
nStep = 9
if nStep >= nNextStep then
WScript.Echo strProg & _
" を既に登録されているパスで存在チェック"
if Fso.FileExists( strTarget ) then
nNextStep = 11
end if
end if
nStep = 10
if nStep >= nNextStep then
WScript.Echo strProg & _
" を登録されているパスへコピー (" & _
strTarget & ")"
Call Fso.CopyFile( strProg, strTarget )
end if
nStep = 11
if nStep >= nNextStep then
strCommand = "regsvr32.exe scrobj.dll /u /n "
strCommand = strCommand & "/i:""file://" & strTarget & """"
WScript.Echo strProg & _
" が正しく登録されているのでいったん登録解除 (" & _
strCommand & ")"
' 実行終了を待つ
Call WshShell.Run( strCommand,,True )
end if
nStep = 12
if nStep >= nNextStep then
strTarget = GetSystemDirectory( )
WScript.Echo strProg & _
" をシステムディレクトリへコピー (" & _
strTarget & ")"
if strTarget = "" then
WScript.Echo ErrMessage
WScript.Quit
end if
Call Fso.CopyFile( strProg, strTarget & "\" & strProg )
end if
nStep = 13
if nStep >= nNextStep then
strCommand = "regsvr32.exe scrobj.dll /n "
strCommand = strCommand & "/i:""file://"
strCommand = strCommand & strTarget & "\" & strProg & """"
WScript.Echo strProg & _
" をシステムディレクトリの登録ファイルで登録します (" & _
strCommand & ")"
' 実行終了を待つ
Call WshShell.Run( strCommand,,True )
end if
WScript.Echo EndMessage
| |
|
|
|