January 22, 2008 at 3:53 am
Hi Folks!
My Problem is that I executed a VBScript as an SQL Agent Job and somehow it only runs in background. I can see it in the task manager (with an owner that is the same user that is logged in). But it's invisible! It's not even in the task bar.
I tried:
"
Set ShellWSH = CreateObject("WScript.Shell")
ShellWSH.Exec("notepad.exe")
Set WshShell = Nothing
"
I also tried (same result):
"
Set shell = CreateObject("Wscript.Shell")
shell.Run "notepad.exe",5,True
Set shell = Nothing
"
What can it be???
Thx 4 reading, hope YOU might be able to help me out of that misery!
-->Dankwart
--------------------------------------------------------
[font="Comic Sans MS"]Correct me if I'm wrong[/font]
January 22, 2008 at 9:42 am
It's executed as the SQL server Agent logon. So it's not the console where you logged on, it's a separate console for that user.
Even if you use your use ID, I'm not sure it's the same session in which it runs.
What are you trying to do? If you have a script that executes as your login, then it will work with the SQL Agent one, providing it has the permissions required.
January 22, 2008 at 10:32 am
Thx!
Another session you say... that makes sense. But how can I address the current session? I created a "credential" that maps to the user for which I want the script to be executed. So the task Manager tells me that it is the right user - but apparently the wrong session.
where can I adjust that?
--------------------------------------------------------
[font="Comic Sans MS"]Correct me if I'm wrong[/font]
February 1, 2008 at 1:20 am
Steve Jones - Editor (1/22/2008)
[...] What are you trying to do? If you have a script that executes as your login, then it will work with the SQL Agent one, providing it has the permissions required.
I don't need to be able to observe the process that is started: What means are necessary to use the same session/console as I do when logging in by myself.
Looking forward to reading your answer.
--------------------------------------------------------
[font="Comic Sans MS"]Correct me if I'm wrong[/font]
November 14, 2011 at 6:31 pm
Hi All
i am trying to execute VB script to refresh my excel files.. using Vbscript file through SQL Agent job step.
i have copied VBscript in a file with the extension RefreshExcel.vbs kept in C:\RefreshExcel.vbs
my Excel file (ReportFile1.xlsx) , is kept under this folder (F:\Reports\Reports\)
Below is the script used inside the file (RefreshExcel.vbs)
//---Script code-----------------------------------------------------------------
Dim objXL, objWB
Dim FileLocation, FileName
On Error Resume Next
'lgnConn = 1
FileLocation = "F:\Reports\Reports"
Set objXL = CreateObject("Excel.Application")
objXL.DisplayAlerts = False
FileName = "ReportFile1.xlsx"
'MsgBox (FileLocation & "/" & FileName)
Set objWB = objXL.Workbooks.Open(FileLocation & "/" & FileName)
objWB.EnableConnections
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.Save
objWB.Close
Set objWS = Nothing
Set objWB = Nothing
objXL.Quit
Set objXL = Nothing
'MsgBox ("Refresh Completed")
---------------------------------------------------------------------------------------------------//Script complete
Now when i am trying to call this script file in SQL agent job step as Type(job Properties) cmdExec(OperatingSystem)
cscript "C:\RefreshExcel.vbs"
Issue: job step executed succesfully ,,but without performing any refresh on the excel. So i am not understandig what is going wrong. the same script file work when i am calling it through a batch file (window scheuler task). But it doesnt support to run the file "when user is not logged in"
that is why i want to refresh my excel file through sql agent ,which can be scheduled to any time and cab be run as SQL agent credentials.
Can you please help me on this ...i have tried all the option but nothing working .. found hope by seeing your solution.
Thanks in advance.
Please help me. 🙁
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply