Solved

VB Script Command Shell

Posted on 2006-06-28
4
357 Views
Last Modified: 2010-04-07
Hey Guys,

Just a quick question for all.  I'm writing a script with a function (listed below) using VBS that will copy a 1.7GB file from one server to another server on our network for processing.  We have a batch file in place at the current moment that I'm going to replace with the new script.  While the batch file works, the problem is that I have operators that need to run secondary processes once the copy is complete and with the batch file, they have no way of knowing how long the file takes to transfer other then waiting an appropiate length of time.  

What I'm trying to figure out a simple way of writing to a command window (shell out I suppose) letting the operators know the status of the cop, if the copy is still running or for that matter if it is completed.  Is there a way that I can write to a command window from inside my function (listed below) that will allow me to create some kind of generic message stating that the process is still running or that it is complete?

Sub CopyFile()
      dim fso
      dim FileToBeCopied
      set fso = CreateObject("Scripting.FileSystemObject")
      FileToBeCopied = "C:\Temp\temp\test123.txt"
      CopyLocation = "C:\Temp\test123.txt"
      
      'Time to check for the file
      if fso.FileExists(FileToBeCopied) = True then
            set temp = fso.getfile (FileToBeCopied)
            fso.copyfile FileToBeCopied, CopyLocation
                  If fso.FileExists(Copylocation)
                        response.write "File has been copied.  <-- will not write to a command window.
                                Set temp = fso.getfile (FileToBeCopied)
                        temp.delete
                        response.write "Original File Deleted"                                                      
      End If
End Sub

Thanks,

Pete J.




0
Comment
Question by:PJan8724
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 17005692
Hi Pete,

I would suggest writing to either the NT System/Application Log (so that your operators can read this remotely from their own machines), or to a bespoke log file you create in a pre-defined (network) location in your code that can be concurrently read by your operators (using a suitable text editor, e.g. TextPad) whilst it is open for write access by your code.

There are also (share/freeware, and commercial) utilities available that can send SMS messages to a pager or a mobile telephone number when a task completes.  You may like to consider the copy process informing your operators by way of their mobile telephone handset that it is complete in this manner.

BFN,

fp.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 17294937
Hi again Dan,

In the absence of any reply based on the only comment made by an expert (myself), I cannot say where the methods I suggested would be suitable for the individual case, but they are all viable options for others to consider.

At the very least I would like to see this question PAQ'ed (with no points refund), but if my comment is considered to be acceptable, then obviously please take this as the solution.

Thanks.

BFN,

fp.
0
 
LVL 1

Author Comment

by:PJan8724
ID: 17296391
Hey funpages and Dan,

Sorry about that, I completely forgot that I had this question open, my bad.  However the solution that was provided by funpages is not exactly what I was looking although it is a good idea.  Since our operators remote into the servers to run batch scripts, there is no reason to write to the NT System/Application log or even to write to a log file.  Looking into a log file or the application log for information would just be one more extra step the operators would have to take in an already overloaded schedule, hence the reason I wanted to write to a DOS window.  This way they would see it instantly, without having to look else where for the information.

However since funpages did provide an alternative solution that could work, I'm going to award him the points for effort.

Pete J.

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question