Link to home
Start Free TrialLog in
Avatar of paulwhelan
paulwhelan

asked on

Adding a VB 'Job' in SQL Enterprise Manager

Hi

I added a Job in Enterprise manager and this is the script

set FSO = server.createobject("Scripting.FileSystemObject")
set filewriter = FSO.createtextfile("d:/yourdirectory/yourfile.html")
filewriter.writeline "hello world"

set fso = nothing
set filewriter = nothing

And I set it to run every minute.

However
1 - nothing was created on my harddisk
2 - i cant seem to go back to edit or view the job?

thanks
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

set FSO = server.createobject("Scripting.FileSystemObject")
set filewriter = FSO.createtextfile("d:/yourdirectory/yourfile.html")
filewriter.writeline "hello world"
filewriter.close
set fso = nothing
set filewriter = nothing

where is the drive D: (ie is it a local harddisk)
is the sql server local on your computer or on a remote server?

2) well, possibly you didn't create the job correctly, hence was not saved, hence did not run.

set filewriter = FSO.createtextfile("d:/yourdirectory/yourfile.html")

should also be:
set filewriter = FSO.createtextfile("d:\yourdirectory\yourfile.html")
Avatar of [ fanpages ]
[ fanpages ]

See my comment in the related question:

"check if a website is 'live'"
[ https://www.experts-exchange.com/questions/21871271/check-if-a-website-is-'live'.html ]

===
Take your VBScript you pasted above & place it in a distinct file external to Enterprise Manager (and give it a ".vbs" extension).

Now set Enterprise Manager to run this .vbs file instead ("Execute Process Task" -> Set "Win32 Process" to be the full folder path/filename where you have saved the .vbs file).

Once you have this working we can look at re-coding the above suggestions in VBScript, rather than in VB(A) as they are shown in the previous comments.
===

BFN,

fp.
Avatar of paulwhelan

ASKER

Hi fanpages

Where is "Execute Process Task"?
Should I do
Tools
Job Scheduling?

If I do that it gives me three options

TSQL command
Operating system shell command (eg run a batch script or invoke an application)
Active script (vbscript or javascript)

If I select Operation system shell command
it says
"type the Operating system shell command you want this job to execute"

What do I type here?

Thanks
Paul

angel

Thanks
Im trying
set filewriter = FSO.createtextfile("d:\yourdirectory\yourfile.html")
now
So i will let you know

Also is there a way to view / edit old jobs?
I cant seem to find the ones i created
ASKER CERTIFIED SOLUTION
Avatar of [ fanpages ]
[ fanpages ]

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
angel
That didn't seem to work either
Would there be a simple insert i could do into my database instead of the 'write to d:'
thanks
paul
set FSO = server.createobject("Scripting.FileSystemObject")

should it be


set FSO = wscript.createobject("Scripting.FileSystemObject")