PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Scheduled script problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Scheduled script problem

Réponse
 
LinkBack Outils de la discussion
Vieux 16/11/2007, 04h15   #1
dk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Scheduled script problem

Here is the problem:
A vbs script that sets up a command to run a batch file, calls EXEC on the
command. When run from a scheduled task, it hangs on the EXEC command,
until the scheduler stops the script after the maximum allowed time to run.
If the EXEC command is commented out, the script does some other work and
completes.
The scheduled task is set to run with user permissions set explicitly for
this type of task. When the same user logs in directly and executes the
script from the command line, the batch file and vbs script completes
without problem. User has rights to run and read write in the directory
where the script resides. The user has rights to run the batch file in the
directory where the batch file resides. The user has rights to create files
at root of C: where a process the batch file kicks off wants to write.
Again, works successfully when run from the command line: cscript (or
wscript) EXAMPLENAME.VBS

Any ideas what could be wrong?

Example of what the script is doing:
Dim oShell
dim logFile
set outerFSO = CreateObject("Scripting.FileSystemObject")
set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
logFile.WriteLine("Log file created")
Set oShell = CreateObject("WScript.Shell")
strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
c:\tmp\temp.txt"
logFile.WriteLine(strPath)
oShell.exec strPath
logFile.WriteLine("Exiting script")

CreateYesterdayName is a function that creates the desired file name.

Thank you,
D.


  Réponse avec citation
Vieux 16/11/2007, 08h29   #2
Kai.Bluesky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

Dear,

May i know the return of strPath?
you may add Wscript.Echo strPath just before oShell.exec strPath.

Hope it may .

Best Regards,
Kai

On Nov 16, 12:15 pm, "dk" <kaa...@hotmail.com> wrote:
> Here is the problem:
> A vbs script that sets up a command to run a batch file, calls EXEC on the
> command. When run from a scheduled task, it hangs on the EXEC command,
> until the scheduler stops the script after the maximum allowed time to run.
> If the EXEC command is commented out, the script does some other work and
> completes.
> The scheduled task is set to run with user permissions set explicitly for
> this type of task. When the same user logs in directly and executes the
> script from the command line, the batch file and vbs script completes
> without problem. User has rights to run and read write in the directory
> where the script resides. The user has rights to run the batch file in the
> directory where the batch file resides. The user has rights to create files
> at root of C: where a process the batch file kicks off wants to write.
> Again, works successfully when run from the command line: cscript (or
> wscript) EXAMPLENAME.VBS
>
> Any ideas what could be wrong?
>
> Example of what the script is doing:
> Dim oShell
> dim logFile
> set outerFSO = CreateObject("Scripting.FileSystemObject")
> set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
> logFile.WriteLine("Log file created")
> Set oShell = CreateObject("WScript.Shell")
> strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
> Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
> c:\tmp\temp.txt"
> logFile.WriteLine(strPath)
> oShell.exec strPath
> logFile.WriteLine("Exiting script")
>
> CreateYesterdayName is a function that creates the desired file name.
>
> Thank you,
> D.

  Réponse avec citation
Vieux 16/11/2007, 14h45   #3
Tom Lavedas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

On Nov 15, 11:15 pm, "dk" <kaa...@hotmail.com> wrote:
> Here is the problem:
> A vbs script that sets up a command to run a batch file, calls EXEC on the
> command. When run from a scheduled task, it hangs on the EXEC command,
> until the scheduler stops the script after the maximum allowed time to run.
> If the EXEC command is commented out, the script does some other work and
> completes.
> The scheduled task is set to run with user permissions set explicitly for
> this type of task. When the same user logs in directly and executes the
> script from the command line, the batch file and vbs script completes
> without problem. User has rights to run and read write in the directory
> where the script resides. The user has rights to run the batch file in the
> directory where the batch file resides. The user has rights to create files
> at root of C: where a process the batch file kicks off wants to write.
> Again, works successfully when run from the command line: cscript (or
> wscript) EXAMPLENAME.VBS
>
> Any ideas what could be wrong?
>
> Example of what the script is doing:
> Dim oShell
> dim logFile
> set outerFSO = CreateObject("Scripting.FileSystemObject")
> set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
> logFile.WriteLine("Log file created")
> Set oShell = CreateObject("WScript.Shell")
> strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
> Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
> c:\tmp\temp.txt"
> logFile.WriteLine(strPath)
> oShell.exec strPath
> logFile.WriteLine("Exiting script")
>
> CreateYesterdayName is a function that creates the desired file name.
>
> Thank you,
> D.


Did you specify that the script is to run Interactive? The Exec
command needs a command console, which is not possible if the
operation does not run interactive. In addition, as I understand it,
unless a user is logged in to the workstation such interactive
operations still will fail.

The correct approach, I think, is to replace the Exec with a Run with
it's operation 'hidden', something like this ...

oShell.Run strPath, 0, true

If you want to catch the return code for your log function, try
this ...

Dim nRes
nRes = oShell.Run strPath, 0, true
logFile.WriteLine "Exiting script with exit code: " & nRes

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  Réponse avec citation
Vieux 16/11/2007, 14h49   #4
Tom Lavedas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

On Nov 16, 9:45 am, Tom Lavedas <tglba...@cox.net> wrote:
> On Nov 15, 11:15 pm, "dk" <kaa...@hotmail.com> wrote:
>
>
>
> > Here is the problem:
> > A vbs script that sets up a command to run a batch file, calls EXEC on the
> > command. When run from a scheduled task, it hangs on the EXEC command,
> > until the scheduler stops the script after the maximum allowed time to run.
> > If the EXEC command is commented out, the script does some other work and
> > completes.
> > The scheduled task is set to run with user permissions set explicitly for
> > this type of task. When the same user logs in directly and executes the
> > script from the command line, the batch file and vbs script completes
> > without problem. User has rights to run and read write in the directory
> > where the script resides. The user has rights to run the batch file in the
> > directory where the batch file resides. The user has rights to create files
> > at root of C: where a process the batch file kicks off wants to write.
> > Again, works successfully when run from the command line: cscript (or
> > wscript) EXAMPLENAME.VBS

>
> > Any ideas what could be wrong?

>
> > Example of what the script is doing:
> > Dim oShell
> > dim logFile
> > set outerFSO = CreateObject("Scripting.FileSystemObject")
> > set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
> > logFile.WriteLine("Log file created")
> > Set oShell = CreateObject("WScript.Shell")
> > strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
> > Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
> > c:\tmp\temp.txt"
> > logFile.WriteLine(strPath)
> > oShell.exec strPath
> > logFile.WriteLine("Exiting script")

>
> > CreateYesterdayName is a function that creates the desired file name.

>
> > Thank you,
> > D.

>
> Did you specify that the script is to run Interactive? The Exec
> command needs a command console, which is not possible if the
> operation does not run interactive. In addition, as I understand it,
> unless a user is logged in to the workstation such interactive
> operations still will fail.
>
> The correct approach, I think, is to replace the Exec with a Run with
> it's operation 'hidden', something like this ...
>
> oShell.Run strPath, 0, true
>
> If you want to catch the return code for your log function, try
> this ...
>
> Dim nRes
> nRes = oShell.Run strPath, 0, true
> logFile.WriteLine "Exiting script with exit code: " & nRes
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/


Opps, there's an error in that nest to the last line of code. It
should read ...

nRes = oShell.Run(strPath, 0, true)

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  Réponse avec citation
Vieux 16/11/2007, 21h15   #5
dk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

Thank you Tom.
I don't have admin rights on the server, so I did not set up the scheduled
operation. Nor can I look at it. So I don't know (yet) if the script can
run interactive.

I think I had already tried the Run command, but now I'm getting different
result, at least when running the script from the command line.

With the Run command, I now get the error:
No application is associated with the specified file for this operation.

So I assume that a separate shell that is being launched to run the strPath
doesn't know about the standard file extensions and how to run them.

"Tom Lavedas" wrote:

> On Nov 16, 9:45 am, Tom Lavedas <tglba...@cox.net> wrote:
> > On Nov 15, 11:15 pm, "dk" <kaa...@hotmail.com> wrote:
> >
> >
> >
> >
> > > Example of what the script is doing:
> > > Dim oShell
> > > dim logFile
> > > set outerFSO = CreateObject("Scripting.FileSystemObject")
> > > set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
> > > logFile.WriteLine("Log file created")
> > > Set oShell = CreateObject("WScript.Shell")
> > > strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
> > > Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
> > > c:\tmp\temp.txt"
> > > logFile.WriteLine(strPath)
> > > oShell.exec strPath
> > > logFile.WriteLine("Exiting script")

> >
> >
> > Did you specify that the script is to run Interactive? The Exec
> > command needs a command console, which is not possible if the
> > operation does not run interactive. In addition, as I understand it,
> > unless a user is logged in to the workstation such interactive
> > operations still will fail.
> >
> > The correct approach, I think, is to replace the Exec with a Run with
> > it's operation 'hidden', something like this ...
> >
> > oShell.Run strPath, 0, true
> >
> > If you want to catch the return code for your log function, try
> > this ...
> >
> > Dim nRes
> > nRes = oShell.Run strPath, 0, true
> > logFile.WriteLine "Exiting script with exit code: " & nRes
> >
> > Tom Lavedas
> > ===========http://members.cox.net/tglbatch/wsh/

>
> Opps, there's an error in that nest to the last line of code. It
> should read ...
>
> nRes = oShell.Run(strPath, 0, true)
>
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/

  Réponse avec citation
Vieux 17/11/2007, 02h22   #6
Kai.Bluesky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

Dear,

You can try psexec to run the bat file.
psexec \\{IP} strPath

ps. It can execute the bat remotely, you can run the script on your
desk.
But this tool need to download.
http://www.microsoft.com/technet/sys...es/psexec.mspx

Hope it may .

Best Regards,
Kai

On Nov 17, 5:15 am, dk <d...@discussions.microsoft.com> wrote:
> Thank you Tom.
> I don't have admin rights on the server, so I did not set up the scheduled
> operation. Nor can I look at it. So I don't know (yet) if the script can
> run interactive.
>
> I think I had already tried the Run command, but now I'm getting different
> result, at least when running the script from the command line.
>
> With the Run command, I now get the error:
> No application is associated with the specified file for this operation.
>
> So I assume that a separate shell that is being launched to run the strPath
> doesn't know about the standard file extensions and how to run them.
>
> "Tom Lavedas" wrote:
> > On Nov 16, 9:45 am, Tom Lavedas <tglba...@cox.net> wrote:
> > > On Nov 15, 11:15 pm, "dk" <kaa...@hotmail.com> wrote:

>
> > > > Example of what the script is doing:
> > > > Dim oShell
> > > > dim logFile
> > > > set outerFSO = CreateObject("Scripting.FileSystemObject")
> > > > set logFile = outerFSO.OpenTextFile("c:\tmp\runreport.log", 2, true)
> > > > logFile.WriteLine("Log file created")
> > > > Set oShell = CreateObject("WScript.Shell")
> > > > strPath = Chr(34) & "C:\Program Files\product name\reports\runreport.bat" &
> > > > Chr(34) & " " & Chr(34) & CreateYesterdayName & Chr(34) & " >
> > > > c:\tmp\temp.txt"
> > > > logFile.WriteLine(strPath)
> > > > oShell.exec strPath
> > > > logFile.WriteLine("Exiting script")

>
> > > Did you specify that the script is to run Interactive? The Exec
> > > command needs a command console, which is not possible if the
> > > operation does not run interactive. In addition, as I understand it,
> > > unless a user is logged in to the workstation such interactive
> > > operations still will fail.

>
> > > The correct approach, I think, is to replace the Exec with a Run with
> > > it's operation 'hidden', something like this ...

>
> > > oShell.Run strPath, 0, true

>
> > > If you want to catch the return code for your log function, try
> > > this ...

>
> > > Dim nRes
> > > nRes = oShell.Run strPath, 0, true
> > > logFile.WriteLine "Exiting script with exit code: " & nRes

>
> > > Tom Lavedas
> > > ===========http://members.cox.net/tglbatch/wsh/

>
> > Opps, there's an error in that nest to the last line of code. It
> > should read ...

>
> > nRes = oShell.Run(strPath, 0, true)

>
> > Tom Lavedas
> > ===========
> >http://members.cox.net/tglbatch/wsh/


  Réponse avec citation
Vieux 20/11/2007, 00h08   #7
dk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scheduled script problem

On Fri, 16 Nov 2007 13:15:01 -0800, dk <dk@discussions.microsoft.com>
wrote:

> Thank you Tom.
> I don't have admin rights on the server, so I did not set up the
> scheduled
> operation. Nor can I look at it. So I don't know (yet) if the script
> can
> run interactive.
>
> I think I had already tried the Run command, but now I'm getting
> different
> result, at least when running the script from the command line.
>
> With the Run command, I now get the error:
> No application is associated with the specified file for this operation.
>
> So I assume that a separate shell that is being launched to run the
> strPath
> doesn't know about the standard file extensions and how to run them.
>
> "Tom Lavedas" wrote:
>

The script works when I log in and run it on the server in question.
My IT guy tries it, from the scheduled task (run now option) and it hangs.
Your suggestion that the script run interactive: That is the default
setting for both cscript and wscript, so why should I set it? I will set
it, but it seems to be a non-issue. Now, whether interactive is allowed
for the account if no one is actually logged in on that account, that is
another story. I'm looking for that info on the net.

dk
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h44.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,24624 seconds with 15 queries