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.

99 lines
2.0 KiB

  1. //
  2. //
  3. // Lists the virtual directories which are BITS upload enabled
  4. // for a given server.
  5. //
  6. function PrintHelp()
  7. {
  8. WScript.Echo( "getbitsurl.js hostname" );
  9. WScript.Quit( 0 );
  10. }
  11. function Pad( str, len )
  12. {
  13. var Ret = str;
  14. while( Ret.length < len )
  15. Ret = Ret + " ";
  16. return Ret;
  17. }
  18. Arguments = WScript.Arguments;
  19. if ( Arguments.length != 1 )
  20. PrintHelp();
  21. if ( Arguments.Item(0) == "/?" )
  22. PrintHelp();
  23. HostName = Arguments.Item(0);
  24. SearchPath = "IIS://"+HostName+"/W3SVC";
  25. Object = GetObject( SearchPath );
  26. var BITSVDIRList;
  27. try
  28. {
  29. BITSVDIRListAsVBArray = Object.GetDataPaths( "BITSUploadEnabled", 0 );
  30. BITSVDIRList = BITSVDIRListAsVBArray.toArray();
  31. }
  32. catch(e){}
  33. var URLs = new Array();
  34. var maxURL = "URL".length;
  35. var VDirs = new Array();
  36. var maxVDir = "Virtual Directory".length;
  37. for( i in BITSVDIRList )
  38. {
  39. BITSVDIR = BITSVDIRList[i];
  40. SearchExp = new RegExp( BITSVDIR.slice( 0, SearchPath.length + 1 ) + "\\d" );
  41. SearchExp.exec( BITSVDIR );
  42. WebSite = RegExp.lastMatch;
  43. ServerBindings = GetObject( WebSite ).ServerBindings.toArray();
  44. /([^:]*):([^:]*):(.*)/.exec( ServerBindings[0] );
  45. URLHostPort = RegExp.$2;
  46. URLHostName = ( RegExp.$3.length > 0 ) ? RegExp.$3 : HostName;
  47. URLPath = BITSVDIR.slice( WebSite.length + "/Root/".length );
  48. URL = "http://"+URLHostName+":"+URLHostPort+"/"+URLPath;
  49. URLs[ URLs.length ] = URL;
  50. VDirs[ VDirs.length ] = URLPath;
  51. }
  52. for( i in URLs )
  53. {
  54. maxURL = Math.max( URLs[i].length, maxURL );
  55. maxVDir = Math.max( VDirs[i].length, maxVDir );
  56. }
  57. WScript.Echo( Pad( "Virtual Directory", maxVDir ) + " " + Pad( "URL", maxURL ) );
  58. var HeaderBar = new String();
  59. for( i=0;i< (maxURL + maxVDir + 1); i++)
  60. HeaderBar = HeaderBar + "-";
  61. WScript.Echo( HeaderBar );
  62. for( i in URLs )
  63. WScript.Echo( Pad( VDirs[i], maxVDir ) + " " + Pad( URLs[i], maxURL ) );