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.

212 lines
4.6 KiB

  1. @ECHO off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. SETLOCAL ENABLEDELAYEDEXPANSION
  5. REM raise the remote if not a tsclient
  6. set script_name=%0
  7. if not exist "%USERPROFILE%\%computername%.ini" goto :EOF
  8. for /f "tokens=1,2* delims== " %%f in ('type "%USERPROFILE%\%computername%.ini"') do (
  9. if /i "%%f" equ "set" (
  10. set %%g=%%h
  11. )
  12. )
  13. if not defined __NTDRIVE set __NTDRIVE=d:
  14. if not defined RemoteStartUpJob set RemoteStartUpJob=@echo.
  15. set platform=
  16. set frechk=
  17. set TSClient=
  18. set default_temp=%tmp:~-1%
  19. set /a default_temp_bak=%default_temp%+0
  20. if "%default_temp%" equ "%default_temp_bak%" set TSClient=1
  21. :Start
  22. call :Win64 %PROCESSOR_ARCHITECTURE%
  23. call :Free free
  24. REM Create UserDefine Remote with UserDefined Arguments
  25. for /L %%a in (0,1,10) do (
  26. if defined UserDefined_%%a (
  27. call :RemoteCreator !UserDefined_%%a!
  28. )
  29. )
  30. REM Create Remote console
  31. for %%a in (%ntroot%) do (
  32. for %%b in (%platforms%) do (
  33. call :Win64 %%b
  34. for %%c in (%frechks%) do (
  35. call :Free %%c
  36. for %%d in (%consoles%) do (
  37. call :RemoteCreator %%a %%a_%%b_%%c_%%d %%b %RemoteStartUpJob%
  38. )
  39. )
  40. )
  41. )
  42. goto end
  43. REM
  44. REM Function: RemoteCreator(__NTROOT __ConsoleName __Platform[ __Dosomething1[+__Dosomething2])
  45. REM Parameter:
  46. REM __NTROOT - the nt's sdxroot
  47. REM __ConsoleName - the console name for we create the window
  48. REM __Platform - x86 or ia64
  49. REM __DoSomething - Do something inside the remote we created
  50. REM Return:
  51. REM none
  52. REM
  53. :RemoteCreator
  54. if "%3"=="" goto :EOF
  55. set consoleexist=
  56. set __NTROOT=%1
  57. set __ConsoleName=%2
  58. set __Platform=%3
  59. set __DoSomething=%4
  60. :AddParameter
  61. shift /4
  62. if "%4" neq "" (
  63. set __DoSomething=!__DoSomething! %4
  64. goto :AddParameter
  65. )
  66. set __DoSomething=%__DoSomething:+=^&^&%
  67. set CreateResult=
  68. set __RemotePath=%__NTDRIVE%\%__NTROOT%\tools\%PROCESSOR_ARCHITECTURE%\remote.exe
  69. call :CheckConsole %__ConsoleName%
  70. if not defined __DoSomething set __DoSomething=@echo.
  71. if not defined consoleexist (
  72. if not defined TSClient (
  73. start /I /min %__RemotePath% /s "cmd /k %__NTDRIVE%\%__NTROOT%\tools\razzle.cmd !platform! !frechk! binaries_dir=d:\%__NTROOT%.binaries postbld_dir=d:\%__NTROOT%.relbins temp=d:\%__NTROOT%.temp.%__Platform% no_title ^&^& title %__ConsoleName% - Remote /c %computername% %__ConsoleName% ^&^& %__DoSomething%" %__ConsoleName% /V /F lyellow /B cyan %Permission%
  74. set CreateResult=ServerCreated
  75. ) else (
  76. start /I /min %__RemotePath% /c %computername% %__ConsoleName% /F lyellow /B cyan
  77. sleep 10
  78. set CreateResult=ClientCreated
  79. )
  80. call :CheckConsole %__ConsoleName%
  81. ) else (
  82. set CreateResult=RemoteExist
  83. )
  84. if not defined consoleexist (
  85. if "%CreateResult%" equ "ServerCreated" (
  86. set CreateResult=ServerFatalError
  87. echo Server Remote does not create successfully....
  88. sleep 10
  89. )
  90. if "%CreateResult%" equ "ClientCreated" (
  91. set CreateResult=ServerRemoteUnavailable
  92. echo Server Remote is not available in this moment....
  93. call :submitprocess %script_name%
  94. sleep 10
  95. )
  96. if "%CreateResult%" equ "RemoteExist" (
  97. REM Retry, because the origional is exist...
  98. goto :RemoteCreator
  99. )
  100. )
  101. set __DoSomething=
  102. goto :EOF
  103. REM
  104. REM Function: Win64(platformname)
  105. REM Parameter:
  106. REM %1 - ia64, x86, ...
  107. REM Return:
  108. REM set platform to win64 if %1 is ia64 or undef if others.
  109. REM
  110. :Win64
  111. if /i "%1"=="ia64" (
  112. set platform=Win64
  113. ) else (
  114. set platform=
  115. )
  116. goto :EOF
  117. REM
  118. REM Function: Free(frechk)
  119. REM Parameter:
  120. REM %1 - fre or chk
  121. REM Return:
  122. REM set frechk to "free" if is %1 is fre, or undef if is chk.
  123. REM
  124. :Free
  125. if /i "%1"=="fre" (
  126. set frechk=free
  127. ) else (
  128. set frechk=
  129. )
  130. goto :EOF
  131. REM
  132. REM Function: CheckConsole(ConsoleName)
  133. REM Parameter:
  134. REM ConsoleName - The Title of the cmd console, we can use it to find in tlist.
  135. REM Return:
  136. REM consoleexist - set to 1 if exist, or undef if not.
  137. REM
  138. :CheckConsole
  139. set ConsoleName=%1
  140. set Consoleexist=
  141. for /f "tokens=1 delims=#" %%k in ('tlist') do (
  142. set TestValue=%%k
  143. if "!TestValue:%ConsoleName%=!" neq "!TestValue!" (
  144. set consoleexist=1
  145. echo Console %ConsoleName% exist....
  146. )
  147. )
  148. if not defined consoleexist echo Console %ConsoleName% not found ...
  149. goto :EOF
  150. REM
  151. REM Function: SubmitProcess(ProgramName)
  152. REM Parameter:
  153. REM ProgramName - the program we would like to call after 3 minutes in the server
  154. REM Return:
  155. REM none
  156. REM
  157. :SubmitProcess
  158. set ProgramName=%1
  159. for /f "tokens=1,2 delims=:." %%k in ('echo %time%') do (
  160. set myhour=%%k
  161. set /A mymin=%%l + 3
  162. if !mymin! gtr 59 (
  163. set /A mymin-=60
  164. set /A myhour+=1
  165. )
  166. if !myhour! gtr 23 (
  167. set /A myhour-=24
  168. )
  169. )
  170. echo Submit remote %1 into server. Should be available at %myhour%:%mymin%.
  171. AT %myhour%:%mymin% /interactive ""%1""
  172. goto :EOF
  173. :end
  174. ENDLOCAL