|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VBS works on Client, Not on Server
I am able to run some VBScript on my workstation but am unable to run
it on the server. No errors. It simply doesn't respond like it does on my workstation. Is there something I need to turn on on the Windows 2003 server so that VBS works? Thanks, RBollinger On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: You may need to invoke the script with cscript. What response is> I am able to run some VBScript on my workstation but am unable to run > it on the server. No errors. It simply doesn't respond like it does > on my workstation. Is there something I need to turn on on the > Windows 2003 server so that VBS works? > > Thanks, > > RBollinger expected? If it is using WMI you need to make sure that the WMI class is supported on W2K3.
Show quote
On Mar 14, 1:20 am, "bg" <bryang***@gmail.com> wrote: Task and Expected Respsonse:> On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: > > > I am able to run some VBScript on my workstation but am unable to run > > it on the server. No errors. It simply doesn't respond like it does > > on my workstation. Is there something I need to turn on on the > > Windows 2003 server so that VBS works? > > > Thanks, > > > RBollinger > > You may need to invoke the script with cscript. What response is > expected? If it is using WMI you need to make sure that the WMI class > is supported on W2K3. This script works with a batch file and task manager to delete files older than a set number of days (e.g., 2) DeleteOld.VBS Set fso=CreateObject("Scripting.FileSystemObject") Set argList=WScript.Arguments If argList.length = 2 Then Set f=fso.GetFolder(argList(0)) Set fc = f.Files For Each f1 in fc If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) Then f1.delete End If Next End If To run it, create a bat file (DeleteOld.bat) that includes the script file name, the destination folder in quotes, and the number of days back from today. DeleteOld.bat DeleteOld.vbs "C:\MyDestinationFolder" 2 The problem is that this script works when I run it on my workstation but fails when I run it on the server. When I run it from my WinXPPro workstation with the target directory open, I see a brief dos window and the old test files disappear. When executing from the server, it completely ignores the script. I'm thinking I need to authenticate the script somehow with the server OS, but have no idea where to start with that. Any suggestions appreciated! Once it functions executing manually at the server, I intend to set up a Schedule Tasks job to run it daily at the server. Thanks, RBollinger
Show quote
On Mar 14, 6:50 am, "robboll" <robb***@hotmail.com> wrote: First thing I would do is add some output to this guy (WScript.Echo "I> On Mar 14, 1:20 am, "bg" <bryang***@gmail.com> wrote: > > > On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: > > > > I am able to run some VBScript on my workstation but am unable to run > > > it on the server. No errors. It simply doesn't respond like it does > > > on my workstation. Is there something I need to turn on on the > > > Windows 2003 server so that VBS works? > > > > Thanks, > > > > RBollinger > > > You may need to invoke the script with cscript. What response is > > expected? If it is using WMI you need to make sure that the WMI class > > is supported on W2K3. > > Task and Expected Respsonse: > > This script works with a batch file and task manager to delete files > older than a set number of days (e.g., 2) > > DeleteOld.VBS > > Set fso=CreateObject("Scripting.FileSystemObject") > Set argList=WScript.Arguments > If argList.length = 2 Then > Set f=fso.GetFolder(argList(0)) > Set fc = f.Files > For Each f1 in fc > If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) > Then > f1.delete > End If > Next > End If > > To run it, create a bat file (DeleteOld.bat) that includes the script > file name, the destination folder in quotes, and the number of days > back from today. > > DeleteOld.bat > > DeleteOld.vbs "C:\MyDestinationFolder" 2 > > The problem is that this script works when I run it on my workstation > but fails when I run it on the server. When I run it from my > WinXPPro > workstation with the target directory open, I see a brief dos window > and the old test files disappear. When executing from the server, it > completely ignores the script. > > I'm thinking I need to authenticate the script somehow with the > server > OS, but have no idea where to start with that. Any suggestions > appreciated! > > Once it functions executing manually at the server, I intend to set up > a Schedule Tasks job to run it daily at the server. > > Thanks, > > RBollinger am here in the script") to see if it is even executing.
Show quote
On Mar 14, 12:23 pm, "bg" <bryang***@gmail.com> wrote: I did that and it seems to be executing. So apparently something is> On Mar 14, 6:50 am, "robboll" <robb***@hotmail.com> wrote: > > > > > > > On Mar 14, 1:20 am, "bg" <bryang***@gmail.com> wrote: > > > > On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: > > > > > I am able to run some VBScript on my workstation but am unable to run > > > > it on the server. No errors. It simply doesn't respond like it does > > > > on my workstation. Is there something I need to turn on on the > > > > Windows 2003 server so that VBS works? > > > > > Thanks, > > > > > RBollinger > > > > You may need to invoke the script with cscript. What response is > > > expected? If it is using WMI you need to make sure that the WMI class > > > is supported on W2K3. > > > Task and Expected Respsonse: > > > This script works with a batch file and task manager to delete files > > older than a set number of days (e.g., 2) > > > DeleteOld.VBS > > > Set fso=CreateObject("Scripting.FileSystemObject") > > Set argList=WScript.Arguments > > If argList.length = 2 Then > > Set f=fso.GetFolder(argList(0)) > > Set fc = f.Files > > For Each f1 in fc > > If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) > > Then > > f1.delete > > End If > > Next > > End If > > > To run it, create a bat file (DeleteOld.bat) that includes the script > > file name, the destination folder in quotes, and the number of days > > back from today. > > > DeleteOld.bat > > > DeleteOld.vbs "C:\MyDestinationFolder" 2 > > > The problem is that this script works when I run it on my workstation > > but fails when I run it on the server. When I run it from my > > WinXPPro > > workstation with the target directory open, I see a brief dos window > > and the old test files disappear. When executing from the server, it > > completely ignores the script. > > > I'm thinking I need to authenticate the script somehow with the > > server > > OS, but have no idea where to start with that. Any suggestions > > appreciated! > > > Once it functions executing manually at the server, I intend to set up > > a Schedule Tasks job to run it daily at the server. > > > Thanks, > > > RBollinger > > First thing I would do is add some output to this guy (WScript.Echo "I > am here in the script") to see if it is even executing.- Hide quoted text - > > - Show quoted text - turned off at the server to prevent the older files from being deleted. Is there a VBScript debugger that you would recommend where I could step to the code on the functioning machine and do the same on the server (i.e. to see what is being ignored on the server). Thanks, RBollinger
Show quote
On Mar 16, 9:59 am, "robboll" <robb***@hotmail.com> wrote: You can try one of the SAPIEN <http://www.sapien.com/products> for> On Mar 14, 12:23 pm, "bg" <bryang***@gmail.com> wrote: > > > > > > > On Mar 14, 6:50 am, "robboll" <robb***@hotmail.com> wrote: > > > > On Mar 14, 1:20 am, "bg" <bryang***@gmail.com> wrote: > > > > > On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: > > > > > > I am able to run some VBScript on my workstation but am unable to run > > > > > it on the server. No errors. It simply doesn't respond like it does > > > > > on my workstation. Is there something I need to turn on on the > > > > > Windows 2003 server so that VBS works? > > > > > > Thanks, > > > > > > RBollinger > > > > > You may need to invoke the script with cscript. What response is > > > > expected? If it is using WMI you need to make sure that the WMI class > > > > is supported on W2K3. > > > > Task and Expected Respsonse: > > > > This script works with a batch file and task manager to delete files > > > older than a set number of days (e.g., 2) > > > > DeleteOld.VBS > > > > Set fso=CreateObject("Scripting.FileSystemObject") > > > Set argList=WScript.Arguments > > > If argList.length = 2 Then > > > Set f=fso.GetFolder(argList(0)) > > > Set fc = f.Files > > > For Each f1 in fc > > > If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) > > > Then > > > f1.delete > > > End If > > > Next > > > End If > > > > To run it, create a bat file (DeleteOld.bat) that includes the script > > > file name, the destination folder in quotes, and the number of days > > > back from today. > > > > DeleteOld.bat > > > > DeleteOld.vbs "C:\MyDestinationFolder" 2 > > > > The problem is that this script works when I run it on my workstation > > > but fails when I run it on the server. When I run it from my > > > WinXPPro > > > workstation with the target directory open, I see a brief dos window > > > and the old test files disappear. When executing from the server, it > > > completely ignores the script. > > > > I'm thinking I need to authenticate the script somehow with the > > > server > > > OS, but have no idea where to start with that. Any suggestions > > > appreciated! > > > > Once it functions executing manually at the server, I intend to set up > > > a Schedule Tasks job to run it daily at the server. > > > > Thanks, > > > > RBollinger > > > First thing I would do is add some output to this guy (WScript.Echo "I > > am here in the script") to see if it is even executing.- Hide quoted text - > > > - Show quoted text - > > I did that and it seems to be executing. So apparently something is > turned off at the server to prevent the older files from being > deleted. Is there a VBScript debugger that you would recommend where > I could step to the code on the functioning machine and do the same on > the server (i.e. to see what is being ignored on the server). > > Thanks, > > RBollinger- Hide quoted text - > > - Show quoted text - debugging. I used code my VBScript in Visual Studio 6 before I got hold of PrimalScript to get the debugging capabilities. I think that you can solve your problem by adding some error checking logic in you code, you just need more tracing code. Check for object creation (IsObject), verify arguments, print out the items that you are supposed to be deleting in your for loop. You can also interrogate the Err object after your delete operation. Also make sure that you Trim() your strings; particularly from the command line. You can also check the event logs for any errors that manifest right after running your script on the server. Most likely in the security and application logs.
Show quote
On Mar 19, 12:05 am, "bg" <bryang***@gmail.com> wrote: Ah. In your code fc is a collection of File objects; File objects do> On Mar 16, 9:59 am, "robboll" <robb***@hotmail.com> wrote: > > > > > > > On Mar 14, 12:23 pm, "bg" <bryang***@gmail.com> wrote: > > > > On Mar 14, 6:50 am, "robboll" <robb***@hotmail.com> wrote: > > > > > On Mar 14, 1:20 am, "bg" <bryang***@gmail.com> wrote: > > > > > > On Mar 13, 1:39 pm, "robboll" <robb***@hotmail.com> wrote: > > > > > > > I am able to run some VBScript on my workstation but am unable to run > > > > > > it on the server. No errors. It simply doesn't respond like it does > > > > > > on my workstation. Is there something I need to turn on on the > > > > > > Windows 2003 server so that VBS works? > > > > > > > Thanks, > > > > > > > RBollinger > > > > > > You may need to invoke the script with cscript. What response is > > > > > expected? If it is using WMI you need to make sure that the WMI class > > > > > is supported on W2K3. > > > > > Task and Expected Respsonse: > > > > > This script works with a batch file and task manager to delete files > > > > older than a set number of days (e.g., 2) > > > > > DeleteOld.VBS > > > > > Set fso=CreateObject("Scripting.FileSystemObject") > > > > Set argList=WScript.Arguments > > > > If argList.length = 2 Then > > > > Set f=fso.GetFolder(argList(0)) > > > > Set fc = f.Files > > > > For Each f1 in fc > > > > If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) > > > > Then > > > > f1.delete > > > > End If > > > > Next > > > > End If > > > > > To run it, create a bat file (DeleteOld.bat) that includes the script > > > > file name, the destination folder in quotes, and the number of days > > > > back from today. > > > > > DeleteOld.bat > > > > > DeleteOld.vbs "C:\MyDestinationFolder" 2 > > > > > The problem is that this script works when I run it on my workstation > > > > but fails when I run it on the server. When I run it from my > > > > WinXPPro > > > > workstation with the target directory open, I see a brief dos window > > > > and the old test files disappear. When executing from the server, it > > > > completely ignores the script. > > > > > I'm thinking I need to authenticate the script somehow with the > > > > server > > > > OS, but have no idea where to start with that. Any suggestions > > > > appreciated! > > > > > Once it functions executing manually at the server, I intend to set up > > > > a Schedule Tasks job to run it daily at the server. > > > > > Thanks, > > > > > RBollinger > > > > First thing I would do is add some output to this guy (WScript.Echo "I > > > am here in the script") to see if it is even executing.- Hide quoted text - > > > > - Show quoted text - > > > I did that and it seems to be executing. So apparently something is > > turned off at the server to prevent the older files from being > > deleted. Is there a VBScript debugger that you would recommend where > > I could step to the code on the functioning machine and do the same on > > the server (i.e. to see what is being ignored on the server). > > > Thanks, > > > RBollinger- Hide quoted text - > > > - Show quoted text - > > You can try one of the SAPIEN <http://www.sapien.com/products> for > debugging. I used code my VBScript in Visual Studio 6 before I got > hold of PrimalScript to get the debugging capabilities. I think that > you can solve your problem by adding some error checking logic in you > code, you just need more tracing code. Check for object creation > (IsObject), verify arguments, print out the items that you are > supposed to be deleting in your for loop. You can also interrogate > the Err object after your delete operation. Also make sure that you > Trim() your strings; particularly from the command line. > > You can also check the event logs for any errors that manifest right > after running your script on the server. Most likely in the security > and application logs.- Hide quoted text - > > - Show quoted text - not have a Delete method. You will need to use the FileSystemObject fso to delete it. See the code below for example. For Each f1 in fc If 0+DateDiff("d",f1.DateLastModified,Date) > 0+argList(1) Then fso.DeleteFile(f1.Path & "\" & f1.name) End If Next I hope this takes care of it for you. > ... A File object *does* have a Delete method...> Ah. In your code fc is a collection of File objects; File objects do > not have a Delete method. ... Delete Method <http://msdn.microsoft.com/library/en-us/script56/html/bc78e712-a749-4037-a4c8-4aa445c38f09.asp?frame=true> -- Michael Harris Microsoft.MVP.Scripting
Show quote
On Mar 19, 7:00 pm, "Michael Harris \(MVP\)" <mikhar.at.mvps.dot.org> Doh! I stand corrected. The script should work as it is, I havewrote: > > ... > > Ah. In your code fc is a collection of File objects; File objects do > > not have a Delete method. ... > > A File object *does* have a Delete method... > > Delete Method > <http://msdn.microsoft.com/library/en-us/script56/html/bc78e712-a749-4...> > > -- > Michael Harris > Microsoft.MVP.Scripting tested on my workstation. Thanks for the insight Michael! |
|||||||||||||||||||||||