1 // AdvancedCopy Manager for Windows
2 // All Rights Reserved, Copyright FUJITSU LIMITED, 2005-2006
3 //
4 // TapeCopyPre.js: Pre-Processing Script for tape copy
5 //
6 // [Parameters]
7 // 1st argument: device name of backup volume
8 //
9 // [Return Values]
10 // 0: The script ended normally.
11 // 2: The number of the arguments is incorrect.
12 // 4: An error other than the above occurred.
13
14 try {
15 // create global objects
16 var WshShell = WScript.CreateObject("WScript.Shell"); // create Shell object
17 var WshEnv = WshShell.Environment("PROCESS"); // create Environment object
18 var fsObj = WScript.CreateObject("Scripting.FileSystemObject"); // create FileSystemObject object
19
20 // create SwstTapeCopyPreProc object
21 var proc = new SwstTapeCopyPreProc();
22
23 // there is nothing to do if the pre/post-processing is not customized
24 proc.doNothingForDriveLetter();
25
26 SwstQuit(0);
27 } catch (e) {
28 SwstQuit(4);
29 }
30
31 function SwstTapeCopyPreProc()
32 {
33 // member variables
34 this.bvName = WScript.Arguments.length!=1?SwstQuit(1):WScript.Arguments.Item(0); // device name of transaction volume
35 this.postFileName = getDataPathName() + "\\" + getPutFileName(this.bvName) + ".pre"; // name of postprocessing file
36
37 // member functions
38 this.doNothingForDriveLetter = doNothingForDriveLetter; // self-explanatory
39 this.writePostFile = writePostFile; // self-explanatory
40 }
41
42 function doNothingForDriveLetter()
43 {
44 this.writePostFile(this.postFileName, "none");
45 }
46
47 function writePostFile(postfile, postdata)
48 {
49 var overwrite = true; // means to overwrite a file if it exists.
50 var postFileStream = fsObj.CreateTextFile(postfile, overwrite);
51 postFileStream.Write(postdata);
52 postFileStream.Close();
53 }
54
55 function SwstQuit(exitStatus)
56 {
57 switch(exitStatus) {
58 case 0:
59 WScript.Quit(0);
60 case 1:
61 WScript.Echo("[Tape copy Preprocessing] The number of the arguments is incorrect.");
62 WScript.Quit(2);
63 default:
64 WScript.Echo("[Tape copy Preprocessing] The script exited abnormally.");
65 WScript.Quit(4);
66 }
67 }
68
69 function getDataPathName()
70 {
71 return WshShell.RegRead(getSetupInfoKey() + "\\etcPathName") + "\\etc\\backup\\data\\DEFAULT";
72 }
73
74 function getSetupInfoKey()
75 {
76 var nodeName = WshEnv.Item("SWSTGNODE");
77 if( nodeName != "" ){
78 return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion\\" + nodeName;
79 }
80 return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion";
81 }
82
83 function getPutFileName(deviceName){
84 var fileName;
85 fileName = deviceName;
86 return(fileName);
87 }
88 |