Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


vbscript as a scheduled task

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,54257
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript as a scheduled task
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 vbscript as a scheduled task - 12/12/2007 6:09:20 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
Hi,
I want to run a vbscript as a windows scheduled task every morning. Somehow it fails...I have even tried creating a batch file that calls the vbs. The batch file starts properly and calls the vbs which doesn't get launched somehow.
The vbs works perfectly fine if I launch it from command prompt or double click.
Can anyone help me out iwth this one please?

Thanks! :)
 
 
Post #: 1
 
 RE: vbscript as a scheduled task - 12/12/2007 8:04:09 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
what does your batch file & scheduled task line look like.

_____________________________

"You start coding. I'll go find out what they want."

(in reply to avkuvalekar)
 
 
Post #: 2
 
 RE: vbscript as a scheduled task - 12/12/2007 8:06:28 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
Hi, as a quick update to the last post, it's not actually the scheduled task also that's creating problems. The script is indeed working but it's getting stalled somewhere because of the oexec that I am using.

following is the code -

const ForReading = 1
const overwriteexisting = TRUE
dim comm
set fso = createobject("scripting.filesystemobject")
set objShell = createobject ("wscript.shell")
comm = " dir h:\ /od | find " & chr(34) & "FoxAdapter" & chr(34)

'msgbox comm
set oExec = objShell.Exec("%comspec% /c " & comm)
'msgbox oexec.status
'Do While oExec.Status = 0

    WScript.Sleep 5000
'Loop
'msgbox oexec.status
set opt = oexec.stdout
while not opt.atendofstream
optline = opt.readline
wend
'msgbox mid(optline,15,20)
start_index = instr(1,optline,"MT",0)
flag = 0
f_name =""
f_name_letter = ""
counter = 0
set f_test_new = fso.createtextfile("C:\mtftest.txt" , True)
f_test_new.writeline(start_index)
f_test_new.close
wscript.quit

i have put this random text file as a test to see where the code is going wrong and i can see that the value of start_index is '0' in my file, essentially implying that the dir command did not execute successfully. can anyone help me out please?

Thanks! :)

(in reply to avkuvalekar)
 
 
Post #: 3
 
 RE: vbscript as a scheduled task - 12/12/2007 8:10:35 PM   
  avkuvalekar

 

Posts: 13
Score: 0
Joined: 11/8/2007
Status: offline
and on further investigation, i realise that even a batch file with a command
dir h:\ /od | find "FoxAdapter" >> C:\mtf_dir.txt
works fine when started manually but when kicked off using a scheduled task, it doesn't do anything...maybe because h:\ is a mapped drive! anybody with any inputs please.

(in reply to avkuvalekar)
 
 
Post #: 4
 
 RE: vbscript as a scheduled task - 12/13/2007 1:56:37 AM   
  mcds99


Posts: 434
Score: 4
Joined: 2/28/2006
Status: offline
If there is no H: drive mapped and the script fails, map the drive.
Don't forget to remove the drive mapping after the job completes.

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to avkuvalekar)
 
 
Post #: 5
 
 RE: vbscript as a scheduled task - 12/14/2007 6:48:59 AM   
  trsix

 

Posts: 21
Score: 0
Joined: 12/6/2006
From: Vancouver BC
Status: offline
this might be a simple thing, but have you checked the following

1. dont log out of your machine and make sure that "run only if logged in" is checked
2. pre-empt the location of your script with              cscript
3. check that the "start in" location is correct

If the script runs fine when launched manually then its prolly one of those things.
I had an issue with one that the "start in" location was causing me grief... took me a couple of days to figure that one out.

hth

(in reply to avkuvalekar)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript as a scheduled task Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts