VbScript on Server 2008
I am having a problem running a vbscript on Server 2008. It used to work till I modified the script. The scripted works great manually and produces the correct end result.
Background: Script runs opens excel and updates all sheets from a connection to a database, and saves the file.
Script attached here:
Dim objExcel, objWorkbook
Set objExcel = CreateObject("Excel.Application")
strPathExcel = "\\XXXXX\"
strFile = "KPI Daily Report"
strSaveFile = strPathExcel & strFile
objExcel.Visible = True
objExcel.Workbooks.open (strPathExcel & strFile & ".xlsx")
objExcel.ActiveWorkbook.RefreshAll
WScript.Sleep 10000 ' Waiting as refresh may take upto ten seconds
objExcel.ActiveWorkbook.SaveAs strSaveFile & "_" & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & ".xlsx"
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
WScript.Quit
Here are my Task scheduler settings:
Run whether user is logged on or not, and Run with Highest Privileges. User account is domain admin.
Configured for Server 2008
Actions:
Action-Start a program
Program/script-%windir%\system32\wscript.exe
No Conditions
Just looking for any help in making this task complete. All ODBC Drivers are installed on the server for System and User DSN as it need that to run manually.
Add Argument (Optional)-"C:\KPI Board Reporting.vbs"
-
There are inconsistencies in your question. If you set it up to run whether or not a user is logged in then if no user is logged in, what is the relevance of domain admin? If you are running the script as local system eg via Kace, then it is going to break in all sorts of ways as the local system account has no profile and the excel object model normally fails to work if a user has not run excel at least once, in order to create the correct excel structure in their profile. - EdT 9 years ago
Answers (0)
Be the first to answer this question