Using WSH to perform a backup 
Author Message
 Using WSH to perform a backup

Using WSH to perform a backup

I am wanting to perform a backup of my data files. In the past I used
a batch file that would use the /s switch to save all subdirectories
for a directory, and the /m switch to save any file that had been
updated (any file that had the archive bit set, and then it would
clear the archive bit).
For example:
xcopy c:\catalog\sysanaly\*.* u:\catalog\sysanaly\*.* /s /m
I can find how to access the subdirectories, but how does one make it
save only files that have been changed?  I don't find anything in WSH
that mimics the /m switch.

You could write a complicated script that checks every same-named file
across the two directory trees to see if they match, but the simplest
and best alternative is to just run the Xcopy command itself.

Dim Shell
Set Shell = CreateObject("Wscript.Shell")
Shell.Run "%comspec% /c xcopy c:\catalog\sysanaly\" &_
               "*.* u:\catalog\sysanaly\*.* /s /m",0,True



Tue, 17 Sep 2002 03:00:00 GMT  
 Using WSH to perform a backup

Using WSH to perform a backupStick with Xcopy, if you try to use WSH the time it will take to complete will make you cry.  You can of course call xcopy using .run

-Mark

  I am wanting to perform a backup of my data files. In the past I used a batch file that would use the /s switch to save all subdirectories for a directory, and the /m switch to save any file that had been updated (any file that had the archive bit set, and then it would clear the archive bit).  

  For example:
  xcopy c:\catalog\sysanaly\*.* u:\catalog\sysanaly\*.* /s /m

  I can find how to access the subdirectories, but how does one make it save only files that have been changed?  I don't find anything in WSH that mimics the /m switch.



Tue, 17 Sep 2002 03:00:00 GMT  
 Using WSH to perform a backup
Open a DOS box, and type: SET, to see a list of the current "Environmental Variables" Your default collection of variables will include windir, and comspec, as well as path, TEMP, prompt, etc. A command line reference to their values can be made by using the percent signs

echo  %conspec% is the location of my command processor.

Windows Script Host has this set of variables available to it, but the syntax to reference them varies from the way it is done with the %% on the command line. If you want a script to run on all platforms,  use them, either from the command line, or with the WSH property for the environment. Actually, your question about them is the reason I avoid their use in example files. It's a steep part of the learning curve that can confuse the point of an example.

--
Mark L. Ferguson       Please reply in Newsgroup
marfers notes for OE 5.0  >  http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm
Re: Using WSH to perform a backupYour help has been excellent!  I was looking through my WSH books and I can't find any information on things like %comspec% and %windir% etc. What kind of components are these and where can I find info to learn about them?  TIA



Wed, 18 Sep 2002 03:00:00 GMT  
 Using WSH to perform a backup

Re: Using WSH to perform a backup%Comspec% and %windir% are
environmental variables that are set by the operating system itself.
The %comspec% variable returns the path of the command interpretor
(such as c:\windows\command.com or c:\winnt\cmd.exe). The %windir%
variable returns the path of the operating system directory, which for
lack of a better definition can be described as the directory that
holds win.ini and system.ini. You or an application on your system can
create environmental variables by adding them to autoexec.bat or
config.sys in Windows '9x, or by using the Control Panel in Windows
NT.
You can see a list of all such variables on your system by typing SET
at a command prompt. Or you can use WSH to see the list. Here are two
different approaches to viewing the list.

 This approach uses the Environment object.

Dim Environment
Dim Variable
Dim EnvVarList
Set Environment = CreateObject("Wscript.Shell").Environment
For Each Variable In Environment
   EnvVarList = EnvVarList & Variable & vbNewLine
Next 'Variable
MsgBox EnvVarList

Approach number two pipes the Dos SET command through cscript, quits
the first instance of the script, which means that it can be run using
wscript, and then reads the list via StdIn.

Dim Shell
Set Shell = CreateObject("Wscript.Shell")
If Wscript.Arguments.Count = 0 Then
   Shell.Run "%comspec% /cset|cscript """ &_
             Wscript.ScriptFullName & """ 1",0,True
   Wscript.Quit
End If
Shell.Popup Wscript.StdIn.ReadAll


Your help has been excellent!  I was looking through my WSH books and
I can't find any information on things like %comspec% and %windir%
etc. What kind of components are these and where can I find info to
learn about them?  TIA



Wed, 18 Sep 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using WSH to perform WAITFOR.EXE like function

2. Using Xcopy and WSH for backup

3. backup to a cd-r using wsh

4. Want to perform non-mailbox Exchange Admin via WSH\ADSI

5. Can't perform a table update using ASP

6. Using JScript to perform Send To Mail Recipient in MS Word

7. Using jscipt to perform a hard refresh

8. New to WSH - Backup Script?

9. Backup files using script

10. Using vbscript to do a CD-RW Backup

11. Backup using a VBScript - Run defragmenter

12. loop functions performed by gsview

 

 
Powered by phpBB® Forum Software