Prev | Current Page 468 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"

In addition, the code
in Listing 6.4 is significantly more complex. However, if you perform just these two comparisons,
you??™ll miss some of the reasons to use scripts. Mostly notably, the script version demonstrates the
flexibility that this form of coding can provide. For example, you have more control over the files.
The input files are read only, which means that the code can??™t damage them, even accidentally.
Consequently, the files are safer than when you use a batch file to manipulate them. Listing 6.4
shows the script version of the CSV output example. You can obtain this example on the Sybex Web
site at http://www.sybex.com/WileyCDA/.
Listing 6.4: Creating CSV Output Using a Script
// Create a File System Object to work with files.
var FSO = WScript.CreateObject(???Scripting.FileSystemObject???);
// Determine whether the Output2.CSV file exists and delete it.
if (FSO.FileExists(???Output2.CSV???))
FSO.DeleteFile(???Output2.CSV???, false);
TESTING SCRIPTS 187
// Create a WshShell object to obtain environment variables.
var Shell = WScript.CreateObject(???WScript.Shell???);
// Create variables to hold the static data.
var CompName = Shell.


Pages:
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
Wróżki ranking kasyn Praca dla pielegniarek Wczasy nad morzem szkolenia dla przedsiębiorców