'Launch Tiny web server. Drop a folder on this 'script (if you want). Tiny will be started with 'logs going to your "temp" folder. Existing 'instances of tiny will be killed. Get tiny from: 'http://www.ritlabs.com/en/products/tinyweb/ Option Explicit Main Sub Main Const TemporaryFolder = 2 Dim strTinyPath, strWebFolder, strLogPath Dim objWMIService, colItems, objItem Dim fs, wsh 'KILL existing instances of tiny Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Name from Win32_Process where Name='tiny.exe'",,48) For Each objItem in colItems objItem.Terminate Next 'Create objects Set wsh = CreateObject("Wscript.Shell") Set fs = CreateObject("Scripting.FileSystemObject") 'Find TINY If fs.FileExists(FileNameInThisDir("tiny.exe")) Then strTinyPath = FileNameInThisDir("tiny.exe") Else strTinyPath = BrowseForFolder("Location of ""tiny.exe"":") If strTinyPath <> "" Then strTinyPath = fs.BuildPath(strTinyPath, "tiny.exe") End If If Not fs.FileExists(strTinyPath) Then MsgBox "Fatal error: Tiny.exe not located." Exit Sub End If If InStr(strTinyPath, " ") <> 0 Then strTinyPath = """" & strTinyPath & """" End If 'Find ROOT strWebFolder = "" If WScript.Arguments.Count = 1 Then strWebFolder = WScript.Arguments(0) If Not fs.FolderExists(strWebFolder) Then strWebFolder = "" End If End If If strWebFolder = "" Then strWebFolder = BrowseForFolder("Folder to serve:") End If If strWebFolder = "" Then MsgBox "Fatal Error: No folder to serve." Exit Sub End If If InStr(strWebFolder, " ") <> 0 Then strWebFolder = """" & strWebFolder & """" End If 'Find LOGS strLogPath = fs.GetSpecialFolder(TemporaryFolder).Path If Instr(strLogPath, " ") <> 0 Then strLogPath = """" & strLogPath & """" End If 'LAUNCH wsh.CurrentDirectory = strLogPath wsh.Run strTinyPath & " " & strWebFolder, 1, 0 End Sub Function FileNameInThisDir(strFileName) 'As String 'Returns the complete path and file name to a file in 'the script directory. For example, "trans.log" might 'return "C:\Program Files\Scripts\Database\trans.log" 'if the script was in the "C:\Program Files\Scripts\Database" 'directory. Dim fs 'As Object Set fs = CreateObject("Scripting.FileSystemObject") FileNameInThisDir = fs.GetAbsolutePathName(fs.BuildPath(Wscript.ScriptFullName, "..\" & strFileName)) ''''''''''Clean up Set fs = Nothing End Function Function BrowseForFolder(strPrompt) 'Uses the "Shell.Application" (only present in Win98 and newer) 'to bring up a file/folder selection window. Falls back to an 'ugly input box under Win95. 'Shell32.ShellSpecialFolderConstants Const ssfPERSONAL = 5 'My Documents Const ssfDRIVES = 17 'My Computer Const SFVVO_SHOWALLOBJECTS = 1 Const SFVVO_SHOWEXTENSIONS = 2 Dim sh, fol, fs, lngView, strPath Set sh = CreateObject("Shell.Application") If Instr(TypeName(sh), "Shell") = 0 Then BrowseForFolder = InputBox(strPrompt, "Select Folder", CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)) Exit Function End If Set fs = CreateObject("Scripting.FileSystemObject") lngView = SFVVO_SHOWALLOBJECTS Or SFVVO_SHOWEXTENSIONS strPath = "" Set fol = sh.BrowseForFolder(&0, strPrompt, lngView, ssfDRIVES) Err.Clear On Error Resume Next strPath = fol.ParentFolder.ParseName(fol.Title).Path 'An error occurs if the user selects a drive instead of a folder If Err.Number <> 0 Then BrowseForFolder = Left(Right(fol.Title, 3), 2) & "\" Else BrowseForFolder = strPath End If End Function