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.

69 lines
1.5 KiB

  1. var args = WScript.Arguments;
  2. if(args.length < 2)
  3. {
  4. WScript.Echo( "Usage: DumpSchema.js <database file> <table> [<index>]" );
  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. var tbl = db.AttachTable( args(1) );
  14. tbl.SelectIndex( args.length == 3 ? args(2) : "", 0 );
  15. if(tbl.Move( 0, -2147483648 /* JET_MoveFirst */ ))
  16. {
  17. while(1)
  18. {
  19. for(var e = new Enumerator( tbl.Columns ); !e.atEnd(); e.moveNext())
  20. {
  21. var col = e.item();
  22. WScript.Echo( "Name = " + col.Name + " Value = " + col.Value );
  23. }
  24. WScript.Echo( "" );
  25. if(tbl.Move( 0, 1 ) == false) break;
  26. }
  27. }
  28. }
  29. catch(e)
  30. {
  31. WScript.Echo( "Error: " + hex( e.number ) + " " + e.description );
  32. }
  33. ////////////////////////////////////////////////////////////////////////////////
  34. function hex( num )
  35. {
  36. var i;
  37. var res = "";
  38. for(i=0;i<8;i++)
  39. {
  40. var mod = num & 0xF;
  41. switch(mod)
  42. {
  43. case 10: mod = "A"; break;
  44. case 11: mod = "B"; break;
  45. case 12: mod = "C"; break;
  46. case 13: mod = "D"; break;
  47. case 14: mod = "E"; break;
  48. case 15: mod = "F"; break;
  49. }
  50. res = mod + res;
  51. num = num >> 4;
  52. }
  53. return res;
  54. }