Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tryin to run .vbs through win2k task scheduler

Status
Not open for further replies.

RhythmAddict112

Programmer
Jun 17, 2004
625
US
Hi all...Im not sure what the issue here is. I'm tryin to run a .vbs script (below) through win task scheduler..Runs fine when I term service into the box and dbl click, but no dice through the scheduler. Im running the task with an account that has local admin rights, and there aren't any drive mappings that are utilized in my script. Clearly, though, I am missing something Any ideas would be great...thought this would be a two second thing.

Code:
connStr = ("Provider=OraOLEDB.Oracle;Data Source=!@#$!@%.world;Persist Security Info=True;user id=@#$@!%;password=@#$%@;dbDBType=Oracle;PLSQLRSet=1;")	
set oConn2 = CreateObject("ADODB.Connection")			
 
oConn2.Open ConnStr
set oCmd2 = CreateObject("ADODB.Command")
oCmd2.ActiveConnection = oConn2


'revise this query to include only queues with zoning on 
oCmd2.CommandText =   	"SELECT DISTINCT q.Q_ID, a.cAdmin_Name, a.contact_address "_
						&"FROM TBL_QUEUE q, TBL_ADMINISTRATORS a, TBL_QUEUE_OPTIONS o "_
						&"WHERE q.q_id = a.q_id AND o.BZONING = 1"
 
 			
oCmd2.CommandType = 1
oCmd2.Prepared = True
set oRs2 = oCmd2.Execute
 
Dim Body
Body = "<BODY bgcolor='#f2f2e6'><UL>"
	Do Until oRs2.EOF
		set oCmd3 = CreateObject("ADODB.Command")
		oCmd3.ActiveConnection = oConn2
		oCmd3.CommandText =  "SELECT COUNT(ID), TXT_PARENT_TICKET_REQUEST_ID, CITY "_
				  			 &"FROM TBL_LOC_NOT_FOUND "_
				   			 &"WHERE Q_ID = " & oRs2.Fields(0) _
				   			 &"GROUP BY TXT_PARENT_TICKET_REQUEST_ID, CITY "
				  		
		
		set oRs3 = oCmd3.Execute

		Dim Cnt 
		Cnt = 0
			Do Until oRs3.Eof
				Body = 	Body + "<BR><LI>" + oRs3.Fields("City") + "</LI>"
				Cnt = Cnt + 1
			oRs3.MoveNext
			Loop
Body = Body + "</UL>"			                                                                     		
Msg = "The application currently has " & Cnt & " unassigned locations for your queue.  "
Msg = Msg + ".  You should navigate to <a href='[URL unfurl="true"]http://something.com/default.htm'>here</a>[/URL] to add these locations and then assign them to zone(s)."

 
 
	Set objMessage = CreateObject("CDO.Message") 
	objMessage.Sender = "sender@somethin.com" 
	'**** Commented out for testing...Real verison would use oRs2.Fields(2) ****
	'objMessage.To = oRs2.Fields(2) 
 	objMessage.To = "someone@somethin.com"
	objMessage.HTMLBody = Msg & "<BR>"  & Body
	objMessage.Subject = "Locations" 
'This section provides the configuration information for the remote SMTP server.
	objMessage.Configuration.Fields.Item _
	("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2 
'Name/IP of SMTP Server
	objMessage.Configuration.Fields.Item _
	("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "myMailServer.myDomain.com"
'Server port  
	objMessage.Configuration.Fields.Item _
	("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25 
	objMessage.Configuration.Fields.Update
	objMessage.Send
	Set objMessage = nothing
	
	oRs2.MoveNext
	Loop

I have also tried to write a .bat file that would launch this .vbs but no dice on that either :-/
 
What does the .bat file have in it? I had a similar problem not long ago and just wrote a basic .bat file to call the .vbs file. Have had no problems running that through Task Scheduler.

My .bat file is in the same directory as the .vbs file and just has the name of the .vbs file in the first line.

Tony
________________________________________________________________________________
 
Hi. thanks for the response..all the .bat file has is this...

Code:
D:\apps\CNF.vbs

which is the directory where the .vbs is located...the bat file is also located in d:\apps\
 
do you have any logging in the vbscript at all???
writing a log file might help? at least you will be able to determine if it iwas actually started.
perhaps the eventlog will give you some indication of what, if anything, happened?
 
Try editing your batch file to:

cscript.exe D:\apps\CNF.vbs

or

wscript.exe D:\apps\CNF.vbs

Maybe?
 
well, i tried cscript, and wscript...no luck on either. I also switched my batch file to reference a test file i created...

test.vbs (works sucessfully when run manually)
Code:
Dim objFileSystem, objOutputFile
Dim strOutputFile

' generate a filename base on the script name
strOutputFile = "./" & Split(WScript.ScriptName, ".")(0) & ".out"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)

objOutputFile.WriteLine("Hello world (" & Now & ")")
objOutputFile.Close

Set objFileSystem = Nothing

WScript.Quit(0)

.bat file reads...(tried cscript and wscript)
Code:
cscript.exe D:\webapps\test.vbs

test.vbs generates a file when its run..nothing was generated :-/
 
Tried changing the bat to just read "test.vbs"..still nothing...


thanks for everyones ongoing advice on this, though!
 
When setting up the task schedular info in the run as box be sure to enter a username with appropriate rights. Also be sure to include the domain name for a domain account (ie.. "your_domain\johndoe") or if it is a local account that this should run under then (ie.. "computer_name\johndoe")
 
Foster, thanks for the response...it has been set up as domain\username since the beginning, unfortunately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top