Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
4.0 KiB

  1. ////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Script to manage file that are written offline
  4. //
  5. ////////////////////////////////////////////////////////////////////////////////////
  6. ////////////////////////////////////////////////////////////////////////////////////
  7. //
  8. //
  9. var c_sdfiles = "sd files -d "; //used to get the local files that need to get added recurively
  10. var c_sdwhere = "sd where "; //used to get local sd mappings
  11. var c_defaultpath = ".\\";
  12. //var c_sdscorch = "del ";//used to add a file to sd, requires filename to be appended
  13. var c_test = false;
  14. var c_help = "Command Line Help for sd_scortch.js\r\n\r\n" +
  15. "This file will DELETE all files that are not checked in" +
  16. "cscript.exe sd_scortch.js [directory] [options]\r\n\r\n" +
  17. "directory Directory to search( must end with '\' )\r\n\r\n " +
  18. "options:\r\n"+
  19. "test Display Actions with out doing them( short form 't' )";
  20. var g_allerrors = "";
  21. var g_fso = new ActiveXObject( "Scripting.FileSystemObject" );
  22. var g_sdfilelist;
  23. var g_shell = new ActiveXObject( "Wscript.Shell" );
  24. //
  25. ////////////////////////////////////////////////////////////////////////////////////
  26. ////////////////////////////////////////////////////////////////////////////////////
  27. //
  28. //
  29. function ProcessCommandArgs( )
  30. {
  31. var i =0;
  32. try
  33. {
  34. if( WScript.Arguments.Length>0 )
  35. {
  36. if( WScript.Arguments( 0 ) =="-?"||WScript.Arguments( 0 ) =="/?" )
  37. {
  38. WScript.Echo( c_help );
  39. WScript.Quit( 0 );
  40. }
  41. for( i=0;i<WScript.Arguments.Length;i++ )
  42. {
  43. switch( WScript.Arguments( i ).substring( 0,2 ) )
  44. {
  45. case "-t":
  46. case "/t":
  47. c_test = true;
  48. break;
  49. case "-v":
  50. case "/v":
  51. c_verbose = true;
  52. break;
  53. case "-l":
  54. case "/l":
  55. c_log = true;
  56. break;
  57. default:
  58. c_defaultpath = WScript.Arguments( i );
  59. break;
  60. }
  61. }
  62. }
  63. }
  64. catch( e )
  65. {
  66. WScript.Echo( "Missing/Bad Argument \r\n" + c_help );
  67. WScript.Quit( 1 );
  68. }
  69. }
  70. ////
  71. ////////////////////////////////////////////////////////////////////////////////////
  72. ////////////////////////////////////////////////////////////////////////////////////
  73. //
  74. //
  75. function InitializeScript( )
  76. {
  77. this.ProcessCommandArgs( );
  78. //do other init logic here
  79. }
  80. //
  81. ////////////////////////////////////////////////////////////////////////////////////
  82. Main();
  83. ////////////////////////////////////////////////////////////////////////////////////
  84. //
  85. //
  86. function Main( )
  87. {
  88. this.InitializeScript();
  89. this.ProcessFolder( this.c_defaultpath );
  90. }
  91. //
  92. /////////////////////////////////////////////////////////////////////////////////////
  93. /////////////////////////////////////////////////////////////////////////////////////
  94. //
  95. //
  96. function ProcessFolder( f )
  97. {
  98. var folders = new Enumerator( g_fso.GetFolder( f ).SubFolders );
  99. for( ;!folders.atEnd();folders.moveNext() )
  100. {
  101. var folder = folders.item();
  102. if( g_fso.FolderExists( folder.Path + "\\bin" ) )
  103. {
  104. WScript.Echo( "Deleting " + folder.Path + "\\bin" );
  105. if( !c_test )
  106. g_fso.DeleteFolder(folder.Path + "\\bin" );
  107. }
  108. if( g_fso.FolderExists( folder.Path + "\\obj" ) )
  109. {
  110. WScript.Echo( "Deleting " + folder.Path + "\\obj" );
  111. if( !c_test )
  112. g_fso.DeleteFolder( folder.Path + "\\obj" );
  113. }
  114. if( g_fso.FolderExists( folder.Path + "\\Debug" ) )
  115. {
  116. WScript.Echo( "Deleting " + folder.Path + "\\Debug" );
  117. if( !c_test )
  118. g_fso.DeleteFolder( folder.Path + "\\Debug" );
  119. }
  120. if( g_fso.FolderExists( folder.Path + "\\Release" ) )
  121. {
  122. WScript.Echo( "Deleting " + folder.Path + "\\Release" );
  123. if( !c_test )
  124. g_fso.DeleteFolder( folder.Path + "\\Release" );
  125. }
  126. }
  127. }
  128. //
  129. /////////////////////////////////////////////////////////////////////////////////////