Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL AGENT JOB - VBScript Expand / Collapse
Author
Message
Posted Tuesday, January 22, 2008 3:53 AM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 23, 2011 5:01 PM
Points: 44, Visits: 113
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


--------------------------------------------------------
Correct me if I'm wrong
Post #445809
Posted Tuesday, January 22, 2008 9:42 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 3:52 PM
Points: 33,268, Visits: 15,440
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.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #445962
Posted Tuesday, January 22, 2008 10:32 AM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 23, 2011 5:01 PM
Points: 44, Visits: 113
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?


--------------------------------------------------------
Correct me if I'm wrong
Post #445993
Posted Friday, February 1, 2008 1:20 AM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, May 23, 2011 5:01 PM
Points: 44, Visits: 113
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.


--------------------------------------------------------
Correct me if I'm wrong
Post #450346
Posted Monday, November 14, 2011 6:31 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 21, 2012 3:39 PM
Points: 26, Visits: 114
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. :-(

Post #1205630
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse