From: munawar on 20 Oct 2009 16:45 Hi I'm terying to programmatically determine information about scheduled task running in a Windows Server 2003 SP1 machine. I've created a vbscript (it will be run locally) which is failing at the following line Set service = CreateObject("Schedule.Service") error message is Microsoft VBScript runtime error: ActiveX component can't create object: 'Scheduler.Service' Now the same code works in a Vista machine. After googling I found out that an assembly called TaskScheduler.dll needs to be present in the machine for this code to work. I found this dll in the Vista machine (where its working) in the following location C:\Windows\winsxs\msil_taskscheduler_31bf3856ad364e35_6.0.6001.18000_none_14fd1dd83f56d37e But its absent in the 2003 machine. Does anybody know how you can get this dll? May be that will solve the problem. I found in one article that this dll comes from Microsoft Site Server 3.0. BTW, I tried putting the dll in the same location in the 2003 machine and registered it using regasm (regsvc was throwing error), although with a warning saying the tlb file was not registered. It still was not working. EggHeadCafe - Software Developer Portal of Choice New IEFT RFC indexed search page http://www.eggheadcafe.com/tutorials/aspnet/aeff2e59-a780-4bfb-ae6d-b88f3813a47e/new-ieft-rfc-indexed-sear.aspx
From: Pegasus [MVP] on 20 Oct 2009 17:50 <munawar rashid> wrote in message news:20091020164536a_m_rashid(a)hotmail.com... > Hi > > I'm terying to programmatically determine information about scheduled task > running in a Windows Server 2003 SP1 machine. I've created a vbscript (it > will be run locally) which is failing at the following line > > Set service = CreateObject("Schedule.Service") > > error message is > > Microsoft VBScript runtime error: ActiveX component can't create object: > 'Scheduler.Service' > > Now the same code works in a Vista machine. After googling I found out > that an assembly called TaskScheduler.dll needs to be present in the > machine for this code to work. I found this dll in the Vista machine > (where its working) in the following location > > C:\Windows\winsxs\msil_taskscheduler_31bf3856ad364e35_6.0.6001.18000_none_14fd1dd83f56d37e > > But its absent in the 2003 machine. Does anybody know how you can get this > dll? May be that will solve the problem. I found in one article that this > dll comes from Microsoft Site Server 3.0. BTW, I tried putting the dll in > the same location in the 2003 machine and registered it using regasm > (regsvc was throwing error), although with a warning saying the tlb file > was not registered. It still was not working. > > > EggHeadCafe - Software Developer Portal of Choice > New IEFT RFC indexed search page > http://www.eggheadcafe.com/tutorials/aspnet/aeff2e59-a780-4bfb-ae6d-b88f3813a47e/new-ieft-rfc-indexed-sear.aspx Under OSs older than Vista you could use the code below. It uses schtask.exe to obtain the details you're after. '------------------------------------ 'Display all selected scheduled tasks '------------------------------------ Dim aTasks(100, 100), iTaskCount 'Array containing a list of all tasks Set oWshShell = CreateObject("WScript.Shell") Set oArgs = WScript.Arguments AllTasks = (oArgs.Count = 0) if not AllTasks then sTask = oArgs(0) if sTask = "*" then AllTasks = True If InStr(sTask, "?") > 0 Then Message "Usage: TaskLister [TaskName or *] [Computer]" if oArgs.count > 1 then sComputer = "/s """ & oArgs(1) & """" Else sComputer = "" Set oExec = oWshShell.Exec("schtasks.exe /query " & sComputer & " /v /fo csv") wscript.sleep 1000 oExec.StdOut.ReadLine 'Blank first line ReadRecord aHeaders 'Read the headers record ReadTasks DisplayTasks '-------------------------------------------- 'Display full details of the selected task(s) '-------------------------------------------- Sub DisplayTasks found = False For i = 0 To iTaskCount If AllTasks Or (UCase(aTasks(i, 1)) = UCase(sTask)) Then For j = 0 To UBound(aHeaders) Desc = aTasks(i, j) If Len(Desc) > 42 Then Desc = Left(Desc, 39) & "..." WScript.Echo Left(aHeaders(j) & Space(37), 37) & Desc Next found = True WScript.Echo End If Next if not found then Message ("Task """ & sTask & """ not found.") End Sub '--------------------------- 'Put all tasks into an array '--------------------------- Sub ReadTasks i = 0 Do While Not oExec.StdOut.AtEndOfStream if i > 99 then Message "100 tasks processed - remaining taks (if any) were ignored" ReadRecord aTemp For j = 0 To UBound(aTemp) aTasks(i, j) = aTemp(j) 'Copy the temp array into the tasks array Next i = i + 1 Loop iTaskCount = i - 1 End Sub '----------------------------------------------- 'Read one record from the output of schtasks.exe '----------------------------------------------- Sub ReadRecord(aRecord) aRecord = Split (oExec.StdOut.ReadLine, """,""") 'Split the CSV fields For i = 0 To UBound(aRecord) aRecord(i) = Replace(aRecord(i), """", "") 'Remove the remaining quotes Next End Sub '------------- 'Error message '------------- Sub Message (sLine) WScript.Echo WScript.Echo sLine WScript.Quit End Sub
|
Pages: 1 Prev: Create website with multiple host headers Next: iTunes script |