Source code of Windows XP (NT5)
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
3.3 KiB

  1. /************************************************************************
  2. Copyright (c) 2000-2000 Microsoft Corporation
  3. Module Name :
  4. bitsenable.cpp
  5. Abstract :
  6. Revision History :
  7. Notes:
  8. ***********************************************************************/
  9. #define INITGUID
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <iadmw.h>
  14. #include <iiscnfg.h>
  15. #include <bitssrvcfg.h>
  16. #include <bitscfg.h>
  17. #include <activeds.h>
  18. #include <malloc.h>
  19. // {A55E7D7F-D51C-4859-8D2D-E308625D908E}
  20. DEFINE_GUID(CLSID_CBITSExtensionSetup,
  21. 0xa55e7d7f, 0xd51c, 0x4859, 0x8d, 0x2d, 0xe3, 0x8, 0x62, 0x5d, 0x90, 0x8e);
  22. void PrintHelp()
  23. {
  24. wprintf(
  25. L"USAGE: bitsenable command\n"
  26. L"The following commands are available:\n"
  27. L"\n"
  28. L"/?\n"
  29. L"/HELP\n"
  30. L"/ENABLE virtual-directory\n"
  31. L"/DISABLE virtual-directory\n"
  32. L"\n" );
  33. exit(0);
  34. }
  35. void CheckError( HRESULT Hr )
  36. {
  37. if (FAILED(Hr))
  38. {
  39. wprintf(L"Error 0x%8.8X\n", Hr );
  40. exit(Hr);
  41. }
  42. }
  43. int _cdecl wmain( int argc, WCHAR**argv )
  44. {
  45. bool Enable;
  46. if ( argc < 2 )
  47. PrintHelp();
  48. if ( _wcsicmp( argv[1], L"/?" ) == 0 )
  49. PrintHelp();
  50. else if ( _wcsicmp( argv[1], L"/HELP" ) == 0 )
  51. PrintHelp();
  52. else if ( _wcsicmp( argv[1], L"/ENABLE" ) == 0 )
  53. Enable = true;
  54. else if ( _wcsicmp( argv[1], L"/DISABLE" ) == 0 )
  55. Enable = false;
  56. else
  57. {
  58. wprintf( L"Unknown command.\n");
  59. PrintHelp();
  60. }
  61. if ( argc != 3 )
  62. {
  63. wprintf( L"Invalid number of arguments.\n");
  64. exit(1);
  65. }
  66. CheckError( CoInitializeEx( NULL, COINIT_MULTITHREADED ) );
  67. IBITSExtensionSetup *ExtensionSetup = NULL;
  68. #if 0
  69. BSTR TaskName = NULL;
  70. ITask *Task = NULL;
  71. LPWSTR Parameters = NULL;
  72. CheckError( ADsGetObject( BSTR( argv[2] ), __uuidof( *ExtensionSetup ), (void**)&ExtensionSetup ) );
  73. CheckError( ExtensionSetup->GetCleanupTaskName( &TaskName ) );
  74. wprintf( L"Cleanup Item name %s\n", (LPCWSTR)TaskName );
  75. CheckError( ExtensionSetup->GetCleanupTask( __uuidof( ITask ), (IUnknown**)&Task ) );
  76. wprintf( L"ITask pointer, %p\n", Task );
  77. if ( Task )
  78. {
  79. CheckError( Task->GetParameters( &Parameters ) );
  80. wprintf( L"Task parameters %s\n", Parameters );
  81. }
  82. exit(0);
  83. #else
  84. IBITSExtensionSetupFactory *ExtensionSetupFactory = NULL;
  85. REFIID CLSID = __uuidof( BITSExtensionSetupFactory ); // CLSID_CBITSExtensionSetup; //;
  86. CheckError(
  87. CoCreateInstance(
  88. CLSID,
  89. NULL,
  90. CLSCTX_INPROC_SERVER,
  91. __uuidof(IBITSExtensionSetupFactory),
  92. (void**)&ExtensionSetupFactory ) );
  93. CheckError( ExtensionSetupFactory->GetObject( BSTR( argv[2] ), &ExtensionSetup ) );
  94. if ( Enable )
  95. {
  96. CheckError( ExtensionSetup->EnableBITSUploads() );
  97. wprintf( L"BITS upload enabled for virtual directory %s\n", argv[2] );
  98. }
  99. else
  100. {
  101. CheckError( ExtensionSetup->DisableBITSUploads() );
  102. wprintf( L"BITS upload disabled for virtual directory %s\n", argv[2] );
  103. }
  104. ExtensionSetup->Release();
  105. ExtensionSetupFactory->Release();
  106. exit(0);
  107. #endif
  108. }