home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
CHIP
/
Tipsy
/
SendM3UtoPlayer
/
sendM3UtoPlayer.vbs
Wrap
Text File
|
2006-11-21
|
4KB
|
131 lines
Option Explicit
Dim listArgs
' Klucz w rejestrze do zintegrowania skryptu do menu
Const constRegKey = "HKEY_CLASSES_ROOT\m3ufile\shell\Wy£lij do odwarzacza MP3\"
Const constRegKeyUninstall = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\sendM3UToPlayer\"
Set listArgs = WScript.Arguments
If listArgs.Count = 0 Then
' Je┐eli brak parametru: Installation
installSkript
Else
If listArgs(0) = "-deinstall" Then
' Deinstlacja
deinstallSkript
Else
sendM3UToPlayer listArgs(0)
End If
End If
Set listArgs = Nothing
' Koniec skryptu
Wscript.Quit
'
' Funcja: sendM3UToPlayer()
' ---------------------------
Function sendM3UToPlayer (strM3UFile)
Dim objM3UFile
Dim objMP3File
Dim objFileSystem
Dim strDrive
Dim strFolder
Dim strMP3File
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
If objFileSystem.FileExists(strM3UFile) Then
strDrive = InputBox("ProszΩ podaµ literΩ napΩdu, odpowiadaj╣c╣ odtwarzaczowi MP3!","Wyb≤r napΩdu","K:\")
If objFileSystem.DriveExists(strDrive) Then
If objFileSystem.FolderExists(strDrive) Then
strFolder = Left(strM3UFile,InStrRev(strM3UFile,"\")-1)
Set objM3UFile = objFileSystem.OpenTextFile(strM3UFile, 1)
Do While Not (objM3UFile.atEndOfStream)
strMP3File = objM3UFile.ReadLine
If Left(strMP3File,1)= "." Then
strMP3File = strFolder & Right(strMP3File, Len(strMP3File) - 1)
End If
If objFileSystem.FileExists(strMP3File) Then
Set objMP3File = objFileSystem.GetFile(strMP3File)
objMP3File.Copy strDrive & "\" & objMP3File.Name, True
Else
MsgBox "Podany plik " & strMP3File & " nie istnieje!"
End If
Loop
objM3UFile.Close
Set objM3UFile = Nothing
MsgBox "Odtwarzacz MP3 za│adowany"
End If
Else
MsgBox "Folderu pod adresem " & strDrive & " nie znaleziono!"
End If
Else
MsgBox "Podany plik " & strM3UFile & " nie istnieje!"
End If
End Function
'
' Funcja: installSkript()
' ---------------------------
Function installSkript ()
Dim objWSHShell
Set objWSHShell = WScript.CreateObject("WScript.Shell")
If (MsgBox("Skrypt bΩdzie dodany do menu kontekstowgo?", vbYesNo + vbQuestion, "Installation?")=vbYes) Then
objWSHShell.RegWrite constRegKey & "command\", """" & WScript.Fullname & """ """ & WScript.ScriptFullName & """ ""%1"""
' Informacje dla systemu...
objWSHShell.RegWrite constRegKeyUninstall & "DisplayName", "VBSkrypt SendM3UToPlayer"
objWSHShell.RegWrite constRegKeyUninstall & "DisplayVersion", "1.0"
objWSHShell.RegWrite constRegKeyUninstall & "HelpLink", "http://www.chip.pl"
objWSHShell.RegWrite constRegKeyUninstall & "Publisher", "CHIP"
objWSHShell.RegWrite constRegKeyUninstall & "UninstallString", """" & WScript.Fullname & """ """ & WScript.ScriptFullName & """ ""-deinstall"""
' Gotowe!
MsgBox "Skrypt """ & WScript.ScriptName & """ dodany do menu!"
End If
Set objWSHShell = Nothing
End Function
'
' Funkcja: deinstallSkript()
' ---------------------------
Function deinstallSkript ()
Dim objWSHShell
Set objWSHShell = WScript.CreateObject("WScript.Shell")
If (MsgBox("Odinsatlowaµ?", vbYesNo + vbQuestion, "Na pewno?")=vbYes) Then
' usuwanie z menu
objWSHShell.RegDelete constRegKey & "command\"
objWSHShell.RegDelete constRegKey
' usuwanie informacji z rejestru
objWSHShell.RegDelete constRegKeyUninstall
End If
Set objWSHShell = Nothing
End Function