batch file

Results 1 to 2 of 2

Thread: batch file

  1. #1
    Join Date
    Dec 1969

    Default batch file

    hai guys<BR><BR> whenever i shut down my machine i want a backup of a particular file to be stored in a centralized repocitory. kindly give me ideas to do this either by using batch files and or else. please help me

  2. #2
    Join Date
    Dec 1969

    Default RE: batch file

    &#039; Haven&#039;t actually checked that this works but the basis is here. OK, its completely hacked up but is should give you an idea. I have included all the command useage to help you out a bit. Remember as this is calling a dos app, long filenames and paths should be in the format abcdef~1.doc etc. Hope it helps. Replace log off with this script. Cool.<BR><BR>currentfilefilename = "name_of_file_to_backup.doc"<BR><BR> &#039; Zip each file; The command line version of winzip addon must me installed (free from winzip site) The command format is: <BR> &#039; winzip32 [-min] action [options] filename[.zip] files<BR> &#039; -min specifies that WinZip should run minimized. If -min is specified, it must be the first command line parameter. <BR> &#039;action<BR> &#039; -a for add, -f for freshen, -u for update, and -m for move. You must specify one (and only one) of these actions. The actions correspond to the actions described in the section titled "Add dialog box options" in the online manual. <BR> &#039; options<BR> &#039; -r corresponds to the Include subfolders checkbox in the Add dialog and causes WinZip to add files from subfolders. Folder information is stored for files added from subfolders. If you add -p, WinZip will store folder information for all files added, not just for files from subfolders; the folder information will begin with the folder specified on the command line. <BR> &#039; -ex, -en, -ef, -es, and -e0 determine the compression method: eXtra, Normal, Fast, Super fast, and no compression. The default is "Normal". -hs includes hidden and system files. Use -sPassword to specify a case-sensitive password. The password can be enclosed in quotes, for example, -s"Secret Password". <BR> &#039;<BR> &#039; Specifies the name of the Zip file involved. Be sure to use the full filename (including the folder). <BR> &#039; files<BR> &#039; Is a list of one or more files, or the @ character followed by the filename containing a list of files to add, one filename per line. Wildcards (e.g. *.bak) are allowed. <BR><BR> &#039;c:progra~1WinZipwinzip32 -u -r -p @c:ackupfilelist.txt - something like this if you want to back up a list of files. See wzzip help for more info.<BR><BR> &#039; Create a WSH Shell object.<BR><BR> Set WshShell = CreateObject("WScript.Shell")<BR> &#039; Start zip process. True specifies script should halt until process has finished. yp for halt<BR> runstring = "wzzip.exe -ex" & " " & "c:ackupdirectory\" & currentfilefilename & ".zip" & " " & "c:path_to_file\" & currentfilefilename<BR> WshShell.Run (runstring)<BR> Set WshShell = nothing<BR><BR>&#039; (1000 = 1 second so increase so that file is given time to backup... you might have to trial and error this...)<BR> WScript.Sleep 1000<BR><BR><BR> Set WshShell = CreateObject("WScript.Shell")<BR> WshShell.Run ("C:WINDOWSRUNDLL32 SHELL32.DLL,SHExitWindowsEx n")<BR> set WshShell = nothing <BR><BR>&#039;Where n is one of the following values, depending on the task you want to accomplish: <BR><BR>&#039;n=0 LOGOFF: Shuts down all running processes, logs the user off, then restarts the Windows shell. (Same as Logoff on the Start Menu.) <BR>&#039;n=1 SHUTDOWN: Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and &#039;all running processes have stopped. <BR>&#039;n=2 REBOOT: Shuts down the system, then restarts it. (Same as Start Menu &#124 Shutdown &#124 Restart.) <BR>&#039;n=4 FORCE: Forces all processes to terminate — in effect, shuts down all running programs. When this flag is set, Windows does not query &#039;running applications to inform them that Windows is shutting down. This can cause the applications to lose data, therefore, you should &#039;only use this flag in an emergency. <BR>&#039;n=8 POWEROFF: Exits Windows, then turns off the computer’s power (provided the computer supports the power-off feature). <BR>&#039;n=-1 RESTART EXPLORER: Quickly closes Explorer (i.e., the Windows desktop), then lets it restore itself. <BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts