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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript issue in scheduler vs command line

Status
Not open for further replies.

romainp

Technical User
Jul 31, 2007
11
CA
Hi,
I have a problem with a vbscript.
This script runs several executable and batch files. when I run the script in a command prompt, all is working correctly. However, when I runs it in explorer (double click on it) on by the task scheduler, it does not seems to work (it does not execute all the commands).
Any help will be greatly appreciated.
Here is the code:
---
Dim objShell
Set objShell = wscript.CreateObject("WScript.Shell")

'=============================

dtmToday = Date()
dtmLastMonth = Date() - 31

'========================================================

iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\rptconnect start batch",1,TRUE)

'========================================================

iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\sdrptrun.bat C:\authmgr\utils\cust_rpt\pcaccept.p" &chr(32) &dtmLastMonth &chr(32) &dtmToday,1,TRUE)
iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\sdrptrun.bat C:\authmgr\utils\cust_rpt\pcincorr.p" &chr(32) &dtmLastMonth &chr(32) &dtmToday,1,TRUE)
iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\sdrptrun.bat C:\authmgr\utils\cust_rpt\sdastart.p" &chr(32) &dtmLastMonth &chr(32) &dtmToday,1,TRUE)

'========================================================

iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\rptconnect stop batch",1,TRUE)

---
 
what user are you using to run the scheduled task? does that user have "logon as a batch job" authority?



RoadKi11

"This apparent fear reaction is typical, rather than try to solve technical problems technically, policy solutions are often chosen." - Fred Cohen
 
In fact for now, it does not even works when I execute the script in windows explorer...
 
Please, define "it does not even works" !

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I will try to gives some additional informations here so maybe to can help me a little more.
As you can see in the code above, the script runs several commands :
- an exe file with some paraneters
- a batch file, that execute come stuff
- an exe file, with some parameters

The batch file called contains itself some commands:
- execute an exe file a parameter
- execute another exe file with a lot of paramters (those parameters are given when the vb script call the batch file)

If I open in windows a command prompt and if I run the script, all is working.
Now, In explorer, if I double click on the vbs file, it seems that the part where the batch file is executed is launched ( I can see a dos box openned) but not executed correctly (the batch should produce some outfile files, which, in the case when the script is executed in explorer by double clicking on it, are not created)

I don't understand why things seems to be different in a dos prompt and in windows explorer when the script is executed.. specially concerning the batch file called.

I will try to post the batch file itself soon but maybe you can give me some hints about what's going on?

thanks
 
Update:
I have remove any references to the batch file and instead integrate the things that were in this bat file in the vbs.

Still have a problem:
When runs from the command line, no problem. When runs from explorer, it does not work.
Here is the actual code:
Dim objShell
Set objShell = wscript.CreateObject("WScript.Shell")

'=============================
dtmToday = Date()
dtmLastMonth = Date() - 31

'========================================================
iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\rptconnect start batch",1,TRUE)

'========================================================

iReturn = objshell.Run("cmd.exe /C c:\authmgr\prog\sdadmlch.exe brokers",1,TRUE)

cmdline1="cmd.exe /C c:\authmgr\util\progui\sdmpro.exe -p c:\authmgr\utils\run.p -param C:\authmgr\utils\cust_rpt\pcaccept.p#" & dtmLastMonth & "#" & dtmToday

iReturn = objshell.Run (cmdline1,1,TRUE)

'========================================================
iReturn = objShell.Run("cmd.exe /C c:\authmgr\utils\rptconnect stop batch",1,TRUE)

'=================

and the old bat file looks like this:
---
@echo off
rem
@"%ACEPROG%\sdadmlch" brokers
@if not errorlevel 1 "%ACEPROG%\progui\sdmpro" -p "%ACEUTIL%\run.p" -param "%1#%2#%3"
---

So what happen in when executed from explorer?
- the first command is run successfully
- the second (the one with lof parameters) start the program but seems lost with the parameters...

But in a dos prompt, all is working
I have change in explorer the way vbs are executed (windows console scripting host instead of windows script host engine) with no luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top