Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL AGENT JOB - VBScript


SQL AGENT JOB - VBScript

Author
Message
dankwart menor
dankwart menor
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 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
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36008 Visits: 18728
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
My Blog: www.voiceofthedba.com
dankwart menor
dankwart menor
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 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
dankwart menor
dankwart menor
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 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
deeep
deeep
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 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. :-(
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search