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.

89 lines
2.3 KiB

  1. var args = WScript.Arguments;
  2. if(args.length != 1)
  3. {
  4. WScript.Echo( "Usage: DumpSchema.js <database file>" );
  5. WScript.Quit( 10 );
  6. }
  7. try
  8. {
  9. var svc = new ActiveXObject( "PCH.HelpService" );
  10. var fso = new ActiveXObject( "Scripting.FileSystemObject" );
  11. var sess = new ActiveXObject( "PCH.DBSession" );
  12. var db = sess.AttachDatabase( fso.GetAbsolutePathName( args(0) ) );
  13. for(var e1 = new Enumerator( db.Tables ); !e1.atEnd(); e1.moveNext())
  14. {
  15. var tbl = e1.item();
  16. WScript.Echo( "Table: " + tbl.Name );
  17. for(var e2 = new Enumerator( tbl.Columns ); !e2.atEnd(); e2.moveNext())
  18. {
  19. var col = e2.item();
  20. WScript.Echo( " Column: Name = " + col.Name );
  21. WScript.Echo( " Type = " + col.Type );
  22. WScript.Echo( " Bits = " + col.Bits );
  23. WScript.Echo( "" );
  24. }
  25. for(var e3 = new Enumerator( tbl.Indexes ); !e3.atEnd(); e3.moveNext())
  26. {
  27. var idx = e3.item();
  28. WScript.Echo( " Index: " + idx.Name );
  29. for(var e4 = new Enumerator( idx.Columns ); !e4.atEnd(); e4.moveNext())
  30. {
  31. var idxcol = e4.item();
  32. WScript.Echo( " Column: Name = " + idxcol.Name );
  33. WScript.Echo( " Type = " + idxcol.Type );
  34. WScript.Echo( " Bits = " + idxcol.Bits );
  35. WScript.Echo( "" );
  36. }
  37. WScript.Echo( "" );
  38. }
  39. WScript.Echo( "" );
  40. }
  41. }
  42. catch(e)
  43. {
  44. WScript.Echo( "Error: " + hex( e.number ) + " " + e.description );
  45. }
  46. ////////////////////////////////////////////////////////////////////////////////
  47. function hex( num )
  48. {
  49. var i;
  50. var res = "";
  51. for(i=0;i<8;i++)
  52. {
  53. var mod = num & 0xF;
  54. switch(mod)
  55. {
  56. case 10: mod = "A"; break;
  57. case 11: mod = "B"; break;
  58. case 12: mod = "C"; break;
  59. case 13: mod = "D"; break;
  60. case 14: mod = "E"; break;
  61. case 15: mod = "F"; break;
  62. }
  63. res = mod + res;
  64. num = num >> 4;
  65. }
  66. return res;
  67. }