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.

73 lines
1.6 KiB

  1. @echo off
  2. REM
  3. REM unrazzle.cmd
  4. REM
  5. REM undoes the setting of environment variables that razzle.cmd does
  6. REM
  7. if "%sdxroot%"=="" (
  8. echo WARN: defaulting sdxroot to z:\nt
  9. set sdxroot=z:\nt
  10. )
  11. if not exist %sdxroot%\tools\razzle.cmd (
  12. echo ERROR: sdxroot\tools\razzle.cmd not found
  13. goto :eof
  14. )
  15. REM
  16. REM These are set indirectly so are not found by the general code.
  17. REM
  18. for %%i in (%_BuildArch% ia64 x86 i386 amd64) do (
  19. set %%i=
  20. set _NT%%iTREE=
  21. )
  22. REM
  23. REM What this is doing is passing the fullpath of this file, %~f0, to perl, and
  24. REM treating the output as variables to clear.
  25. REM -x to Perl makes it skip ahead to the #!perl line.
  26. REM
  27. for %%j in (razzle.cmd ntenv.cmd ntuser.cmd sdinit.cmd) do (
  28. for /f %%i in ('%razzletoolpath%\perl\bin\perl -x %~f0 ^< %sdxroot%\tools\%%j') do set %%i=
  29. )
  30. set Path=%windir%\system32;%windir%;%windir%\System32\Wbem
  31. title %comspec%
  32. goto :eof
  33. #!perl
  34. #line 31
  35. sub MakeLower
  36. {
  37. return lc($_[0]);
  38. }
  39. #
  40. # find all environment variables modified by razzle.cmd by looking for set foo=
  41. #
  42. #
  43. # we should populate this at runtime at least from
  44. # reg query "hklm\system\currentcontrolset\control\session manager\environment" | findstr /i value
  45. #
  46. %preserve=
  47. (
  48. 'processor_architecture' => 1,
  49. 'temp' => 1,
  50. 'tmp' => 1,
  51. 'username' => 1
  52. );
  53. while (<>)
  54. {
  55. if (/set +(\/a +)?([^='%]+)=/i)
  56. {
  57. $x = $2;
  58. $y = MakeLower($x);
  59. if (!$preserve{$y})
  60. {
  61. $vars{$y} = $x;
  62. }
  63. }
  64. }
  65. foreach $var (sort(values(%vars)))
  66. {
  67. printf($var . "\n");
  68. }