by DiddeLeeDoo » Wed Aug 02, 2006 3:06 am
Simple Script Installer
This script is like a container for scripts, and install scripts as defined by the
InstallScriptTo command.
InstallScriptTo "Auto\ScriptName.vbs", LineBegin, LineEnd, "Message after Installation finished"
Code: Select all
'-------------------------OPEN---------------------------------
Dim FSO : Set FSO=CreateObject("Scripting.FileSystemObject")
Dim SDB : Set SDB=CreateObject("SongsDB.SDBApplication")
While Not SDB.isRunning : WScript.Sleep 500 : Wend
'--------------------------------------------------------------
InstallScriptTo "Auto\XXXXXXXXX.vbs", LineBegin, LineEnd , _
_
"Script Successfully Installed!" &vbLf&_
"Please restart MediaMonkey" &vbLf&_
"Other notes to user after install....."
'--------------------------CLOSE-------------------------------
SDB.ShutdownAfterDisconnect=True
Set FSO=Nothing : Set SDB=Nothing : Wscript.Quit
'--------------------------------------------------------------
'This is line 20, and you can paste your script in here and see
'what the end line is to do the InstallScriptTo command options
'
'Like a 100 Line Script would need a command above like
'
'InstallScriptTo "Auto\MyScriptName.vbs", 20, 120, "MessageText"
'%%%%%%%%%%%%%%%%% START OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%
Sub InstallScriptTo(ScriptName, LineBegin, LineEnd, Message)
ScriptName=SDB.ApplicationPath & "Scripts\" & ScriptName
RenameOldScript(ScriptName)
Set TXT=FSO.OpenTextFile(WScript.ScriptFullName,1)
STR=TXT.ReadAll
TXT.Close
LNS=Split(STR,vbNewLine)
Set TXT=FSO.CreateTextFile(ScriptName, True)
For i=LineBegin-1 To LineEnd-1
TXT.WriteLine LNS(i)
Next
TXT.Close
If FSO.FileExists(ScriptName) And Message<>"none" Then _
SDB.MessageBox Message , 2, Array(4)
End Sub
Sub RenameOldScript(ScriptName)
If FSO.FileExists(ScriptName) Then _
FSO.MoveFile ScriptName, BakFile(ScriptName)
End Sub
Function BakFile(ScriptName)
Do
TMP=Left(ScriptName, Len(ScriptName)-3) & "old" & v
v=v+1
Loop While FSO.FileExists(TMP)
BakFile=TMP
End Function
'%%%%%%%%%%%%%%%%%% END OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%%
If having many scripts to install at once, write something like
InstallScriptTo "Auto\MyScriptName.vbs", 20, 120, "none"
InstallScriptTo "MyOtherFileName.vbs", 122, 250, "MessageText"
More stuff can be done too, and many things are happening in the AutoRateSongs Installer, like Scripts.ini modification, Reg read, ini write.
http://www.mediamonkey.com/forum/viewtopic.php?t=9241
[b]Simple Script Installer[/b]
This script is like a container for scripts, and install scripts as defined by the [b]InstallScriptTo[/b] command.
InstallScriptTo "Auto\ScriptName.vbs", LineBegin, LineEnd, "Message after Installation finished"
[code]'-------------------------OPEN---------------------------------
Dim FSO : Set FSO=CreateObject("Scripting.FileSystemObject")
Dim SDB : Set SDB=CreateObject("SongsDB.SDBApplication")
While Not SDB.isRunning : WScript.Sleep 500 : Wend
'--------------------------------------------------------------
InstallScriptTo "Auto\XXXXXXXXX.vbs", LineBegin, LineEnd , _
_
"Script Successfully Installed!" &vbLf&_
"Please restart MediaMonkey" &vbLf&_
"Other notes to user after install....."
'--------------------------CLOSE-------------------------------
SDB.ShutdownAfterDisconnect=True
Set FSO=Nothing : Set SDB=Nothing : Wscript.Quit
'--------------------------------------------------------------
'This is line 20, and you can paste your script in here and see
'what the end line is to do the InstallScriptTo command options
'
'Like a 100 Line Script would need a command above like
'
'InstallScriptTo "Auto\MyScriptName.vbs", 20, 120, "MessageText"
'%%%%%%%%%%%%%%%%% START OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%
Sub InstallScriptTo(ScriptName, LineBegin, LineEnd, Message)
ScriptName=SDB.ApplicationPath & "Scripts\" & ScriptName
RenameOldScript(ScriptName)
Set TXT=FSO.OpenTextFile(WScript.ScriptFullName,1)
STR=TXT.ReadAll
TXT.Close
LNS=Split(STR,vbNewLine)
Set TXT=FSO.CreateTextFile(ScriptName, True)
For i=LineBegin-1 To LineEnd-1
TXT.WriteLine LNS(i)
Next
TXT.Close
If FSO.FileExists(ScriptName) And Message<>"none" Then _
SDB.MessageBox Message , 2, Array(4)
End Sub
Sub RenameOldScript(ScriptName)
If FSO.FileExists(ScriptName) Then _
FSO.MoveFile ScriptName, BakFile(ScriptName)
End Sub
Function BakFile(ScriptName)
Do
TMP=Left(ScriptName, Len(ScriptName)-3) & "old" & v
v=v+1
Loop While FSO.FileExists(TMP)
BakFile=TMP
End Function
'%%%%%%%%%%%%%%%%%% END OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%%
[/code]
If having many scripts to install at once, write something like
InstallScriptTo "Auto\MyScriptName.vbs", 20, 120, "none"
InstallScriptTo "MyOtherFileName.vbs", 122, 250, "MessageText"
More stuff can be done too, and many things are happening in the AutoRateSongs Installer, like Scripts.ini modification, Reg read, ini write.
http://www.mediamonkey.com/forum/viewtopic.php?t=9241