NAS Start Up VBScript (2 Viewers)

PeterDB

Portal Member
March 28, 2010
9
0
Home Country
Switzerland Switzerland
I have been using MediaPortal for a few days now and I love it.

I am using my setup with a QNAP TS-419p NAS with 8TB (running RAID 5 so 5.6 TB) with an Asrock ION330 Pro upgraded to 4GB memory, but when the NAS is in sleep mode it will take maybe 15-30 seconds for it to start up and the files be accessible and in this time MediaPortal often tends to crash or hang until the NAS is woken up.

So, I wrote a small VBScript which creates a small file and then starts a program afterwards. This program can be used to create a file on the NAS and then start MediaPortal, thus avoiding any issues.

Take the code below and copy it into a file called say NASon.vbs. It is important that the file extension is vbs!

You can now modify strPath, strFile and strExecuteProgram to specify respectively what the path should be, what file name should be and what the executed program should be.

Now when you need to start MediaPortal just run this file...


Code:
'------------------------------------------------------------------------------------
' Created by Peter DeBrass (http://debrass.net)
' This small script is designed to create a file on the specified path and include
' the time when the script started and when the file was written.
' The purpose is has various types of NAS devices to power up before starting a
' program, such as MediaPortal.
'------------------------------------------------------------------------------------

'Various needed variables.
Dim strPath, strFileName, strStartDate, strStartTime, strExecuteProgram

'-----------------------------------------------------------------------------------------
' Please specify the precise path to the file which needs to be created, e.g., \\NAS\PATH\
'-----------------------------------------------------------------------------------------
strPath = "\\NAS\PATH\"
'-----------------------------------------------------------------------------------------
' Please provide a name to the file which needs to be created, e.g., NameOfFile
'-----------------------------------------------------------------------------------------
strFileName = "NASon"
'-----------------------------------------------------------------------------------------
' Please provide the full path to the program which needs to executed,
' e.g., C:\Program Files\Team MediaPortal\mp.exe
'-----------------------------------------------------------------------------------------
strExecuteProgram = "notepad"
'-----------------------------------------------------------------------------------------

'--DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU NOW WHAT YOU ARE DOING---------------

'The Date and Time this script was started
strStartDate = Date
strStartTime = Time

'File Object Creation
Set FSO = CreateObject("Scripting.FileSystemObject")

'File Created
Set lf = FSO.OpenTextFile( strPath & strFileName & ".txt", 8, True)

'Information when this script was started and when the file creation was completed is written into the file.
lf.WriteLine("-----------------------------------" &  VbCrLf  & "Script Start:" & VBTab & strStartDate & " " & strStartTime &  VbCrLf & "File Write:" & VBTab & Date & " " & Time & VbCrLf & "-----------------------------------")
lf.Close

'The program is started
Set ss = CreateObject("WScript.Shell")
ss.run strExecuteProgram,1
Set ss = nothing
 

Users who are viewing this thread

Top Bottom