Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.64 KB | None | 0 0
  1. Set Argument=WScript.Arguments
  2. Dim Trace
  3. Trace=0
  4. if Argument.count = 1 then
  5. if Argument(0)="True" then
  6. Trace=1
  7. end if
  8. end if
  9. if Trace=0 then
  10. on error resume next
  11. else
  12. Wscript.Echo "Skript vom 15.01.2015 gestartet!"
  13. end if
  14. '------------------------------------------------------
  15. '----------- Konstanten -------------------------------
  16. Const LW_O="O:" 'QM-Archive
  17. Const LW_P="P:" 'Private
  18. Const LW_Q="Q:" 'Roth
  19. Const LW_R="R:" 'Buchhaltung
  20. Const LW_S="S:" 'Alpha-Reha
  21. Const LW_T="T:" 'Theorg
  22. Const LW_W="W:" 'Wendelstein
  23. Const LW_V="V:" 'Bank
  24. Const LW_Y="Y:" 'Starmoney
  25. Const LW_X="X:" 'Proxomed
  26. Const LW_Z="Z:" 'QM System
  27. Const Server1="ALPHA01"
  28. Const Server2="ALPHA03"
  29. Const Server3="ALPHA02"
  30. Const Server01="SERVER01" 'Roth
  31. Const Server02="SERVER02" 'Roth
  32. Const Server03="SERVER03" 'Roth
  33. Const Server04="SERVER04" 'Wendelstein
  34. Const Server05="SERVER05" 'Fürth
  35. Const Server06="SERVER06" 'Wendelstein
  36. Const US_Administrator="cn=administrator"
  37. Const US_HMUELLER="cn=hans müller"
  38. Const US_EKRUL="cn=empfang fürth"
  39. Const US_HBAUMGAERTEL="cn=heidi baumgärtel"
  40. Const GR_WENDELSTEIN="cn=wendelstein"
  41. Const GR_ROTH="cn=roth"
  42. Const GR_SCHWABACH="cn=schwabach"
  43. Const GR_FUERTH="cn=fuerth"
  44. Const GR_BUCHHALTUNG="cn=buchhaltung"
  45. Const GR_BANK="cn=onlinebanking"
  46. Const GR_NOSKRIPT="cn=noskript"
  47. Const PR_RH_EMPFANG="cn=pr-rh-empfang"
  48. Const PR_WE_EMPFANG="cn=pr-we-empfang"
  49. Const PR_SC_EMPFANG="cn=pr-sc-empfang"
  50. Const PR_RH_MTT="cn=pr-rh-medizinisches training"
  51. Const PR_RH_ERGO="cn=pr-rh-ergo"
  52. Const PR_RH_PHYSIO="cn=pr-rh-physio"
  53. Const PR_RH_ABRECHNUNG="cn=pr-rh-abrechnung"
  54. Const PR_WE_PLANUNG="cn=pr-we-planung"
  55. Const PR_RH_CHEFS="cn=pr-rh-geschaeftsleitung"
  56. Const PC_ALBRECHT="ALPHA281210"
  57. Const PC_TRAINING1="ALPHA261210"
  58. Const PC_KRUL="ALPHA030315"
  59. Const PC_BAUM="ALPHA130214"
  60. Const IP_Roth="61"
  61. Const IP_Wendelstein="60"
  62. Const IP_Schwabach="62"
  63. Const IP_Fuerth="63"
  64. '------------------------------------------------------
  65. '----------- Vorbereitungen ---------------------------
  66. Dim Ergebnis
  67. Set Network=CreateObject("Wscript.Network")
  68. Set Shell=CreateObject("Wscript.Shell")
  69. Set Drives=Network.EnumNetworkDrives
  70. Set ADSysInfo=CreateObject("ADSystemInfo")
  71. Set CurrentUser=GetObject("LDAP://"&ADSysInfo.Username)
  72. UserName=LCase(CurrentUser.Name)
  73. LoginName=CurrentUser.samaccountname
  74. if Trace=1 then Wscript.Echo "Benutzer : " & (UserName)
  75. Set CurrentComp=GetObject("LDAP://"&ADSysInfo.ComputerName)
  76. CompName=LCase(CurrentComp.Name)
  77. if Trace=1 then Wscript.Echo "Computer : " & (CompName)
  78. Select Case VarType(CurrentUser.MemberOf)
  79. Case 0
  80. UserGroups=""
  81. Case 8
  82. UserGroups=LCase(CurrentUser.MemberOf)
  83. Case 8204
  84. UserGroups=LCase(Join(CurrentUser.MemberOf))
  85. End Select
  86. 'UserGroups=LCase(Join(CurrentUser.MemberOf))
  87. if Trace=1 then Wscript.Echo "User Groups : " & (UserGroups)
  88. if CompName<>Server02 and CompName<>Server03 then
  89. Select Case VarType(CurrentComp.MemberOf)
  90. Case 0
  91. CompGroups=""
  92. Case 8
  93. CompGroups=LCase(CurrentComp.MemberOf)
  94. Case 8204
  95. CompGroups=LCase(Join(CurrentComp.MemberOf))
  96. End Select
  97. 'CompGroups=LCase(Join(CurrentComp.MemberOf))
  98. if Trace=1 then Wscript.Echo "Computer Groups : " & (CompGroups)
  99. end if
  100. if Instr(CompGroups,GR_NOSKRIPT) then
  101. if Trace=1 then Wscript.Echo "Abflug !"
  102. Wscript.Quit()
  103. end if
  104. Machine=UCase(Network.ComputerName)
  105. '------------------------------------------------------
  106. '----------- IP Adresse ermitteln ---------------------
  107. dim a1,a2,a3
  108. Set IPConfigSet = GetObject("winmgmts://.").ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
  109. For Each IPConfig In IPConfigSet
  110. if Not IsNull(IPConfig.IPAddress) Then
  111. For i=LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
  112. Ergebnis=IPConfig.IPAddress(i)
  113. a1=instr(Ergebnis,".")
  114. a2=instr(a1+1,Ergebnis,".")
  115. a3=instr(a2+1,Ergebnis,".")
  116. Ergebnis1=left(Ergebnis,a2)
  117. if Ergebnis1="192.168."and IPConfig.IPSubnet(i)<>"64" then
  118. OwnIP=mid(Ergebnis,a2+1,a3-a2-1)
  119. if Trace=1 then Wscript.Echo ("Duooktett : " & Ergebnis1)
  120. end if
  121. if Trace=1 then Wscript.Echo "IPAdresse: " & IPConfig.IPAddress(i) & " Subnet: " & IPConfig.IPSubnet(i)
  122. 'if Trace=1 then WScript.Echo "Subnet: " & IPConfig.IPSubnet(i)
  123. 'if Trace=1 then WScript.Echo "MAC Address " & IPConfig.MACAddress
  124. Next
  125. End If
  126. Next
  127. Ergebnis=OwnIP
  128. if Trace=1 then WScript.Echo "IPNetz: " & Ergebnis
  129. '------------------------------------------------------
  130. '----------- Vorbereitung BFS -------------------------
  131. BFS="ok"
  132. Set objFSO = CreateObject("Scripting.FileSystemObject")
  133.  
  134. If objFSO.FolderExists("V:\BFSPRO") then
  135. BFS="ok"
  136. Else
  137. BFS="nein"
  138. End If
  139. if Trace=1 then WScript.Echo "BFS "& BFS
  140. '------------------------------------------------------
  141. '----------- Laufwerke löschen ------------------------
  142. for i=o to Drives.Count -1 Step 2
  143. if Drives.Item(i)=LW_P then
  144. Network.RemoveNetworkDrive LW_P,true,true
  145. end if
  146. if Drives.Item(i)=LW_R then
  147. Network.RemoveNetworkDrive LW_R,true,true
  148. end if
  149. if Drives.Item(i)=LW_S then
  150. Network.RemoveNetworkDrive LW_S,true,true
  151. end if
  152. if Drives.Item(i)=LW_T then
  153. Network.RemoveNetworkDrive LW_T,true,true
  154. end if
  155. if Drives.Item(i)=LW_U then
  156. Network.RemoveNetworkDrive LW_U,true,true
  157. end if
  158. ' if Drives.Item(i)=LW_V then
  159. ' Network.RemoveNetworkDrive LW_V,true,true
  160. ' end if
  161. if Drives.Item(i)=LW_Q then
  162. Network.RemoveNetworkDrive LW_Q,true,true
  163. end if
  164. if Drives.Item(i)=LW_O then
  165. Network.RemoveNetworkDrive LW_O,true,true
  166. end if
  167. if Drives.Item(i)=LW_W then
  168. Network.RemoveNetworkDrive LW_W,true,true
  169. end if
  170. if Drives.Item(i)=LW_X then
  171. Network.RemoveNetworkDrive LW_X,true,true
  172. end if
  173. if Drives.Item(i)=LW_Z then
  174. Network.RemoveNetworkDrive LW_Z,true,true
  175. end if
  176. next
  177. if Trace=1 then WScript.Echo "Laufwerke gelöscht"
  178. '------------------------------------------------------
  179. '----------- Netzwerkdrucker löschen ------------------
  180. strComputer = "."
  181. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  182. Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer Where Network = True")
  183. if Trace=1 then Wscript.Echo colInstalledPrinters.count & (" Drucker installiert!")
  184. if Trace=1 then Wscript.Echo ("Drucker löschen Vorbereitung abgeschloßen!")
  185. for each objPrinter in colInstalledPrinters
  186. if Trace=1 then Wscript.Echo ("Delete: " & objPrinter.Caption)
  187. objPrinter.Delete_
  188. next
  189. if Trace=1 then Wscript.Echo ("Drucker gelöscht!")
  190. '------------------------------------------------------
  191. if Trace=1 then WScript.Echo "Standardlaufwerke gemappt"
  192. if Instr(UserGroups,GR_ROTH) then
  193. if Trace=1 then WScript.Echo "Laufwerke Roth"
  194. Network.MapNetworkDrive LW_S,"\\SERVER02\ALPHA-REHA"
  195. Network.MapNetworkDrive LW_X,"\\SERVER02\PROXOMED"
  196. Network.MapNetworkDrive LW_Q,"\\SERVER02\ROTH"
  197. if Trace=1 then WScript.Echo "\\SERVER02\BENUTZER\" & Loginname
  198. Network.MapNetworkDrive LW_P,"\\SERVER02\BENUTZER\"&Loginname
  199. Network.MapNetworkDrive LW_Z,"\\SERVER02\QM-ROTH"
  200. Network.MapNetworkDrive LW_O,"\\SERVER02\QM-ROTH ARCHIV"
  201. if Trace=1 then WScript.Echo "Laufwerke verbunden"
  202. if Instr(UserGroups,GR_BANK) then
  203. if Trace=1 then WScript.Echo "Bank"
  204. if BFS="nein" then
  205. Network.MapNetworkDrive LW_V,"\\SERVER01\BANK", true
  206. Network.MapNetworkDrive LW_Y,"\\SERVER01\STARMONEY", true
  207. end if
  208. if Trace=1 then WScript.Echo "Laufwerke Bank verbunden"
  209. end if
  210. if Instr(UserGroups,GR_BUCHHALTUNG) then
  211. if Trace=1 then WScript.Echo "Buchhaltung"
  212. Network.MapNetworkDrive LW_R,"\\SERVER02\BUCHHALTUNG"
  213. Network.MapNetworkDrive LW_W,"\\SERVER04\WENDELSTEIN"
  214. if Trace=1 then WScript.Echo "Laufwerke Buchhaltung verbunden"
  215. end if
  216. Batch="reg import \\SERVER01\ROTH\SharedDocuments.reg"
  217. if Trace=1 then WScript.Echo Batch
  218. Aus=Shell.Run(Batch,0,true)
  219.  
  220. end if
  221. if Instr(UserGroups,GR_WENDELSTEIN) then
  222. if Trace=1 then WScript.Echo "Wendelstein"
  223. Network.MapNetworkDrive LW_S,"\\SERVER02\ALPHA-REHA"
  224. Network.MapNetworkDrive LW_W,"\\SERVER04\WENDELSTEIN"
  225. Network.MapNetworkDrive LW_P,"\\SERVER04\BENUTZER\"&Network.Username
  226. Network.MapNetworkDrive LW_Z,"\\SERVER04\QM-WENDELSTEIN"
  227. Network.MapNetworkDrive LW_O,"\\SERVER04\QM-WENDELSTEIN ARCHIV"
  228. if Trace=1 then WScript.Echo "Laufwerke verbunden"
  229. if Instr(UserGroups,GR_BUCHHALTUNG) then
  230. if Trace=1 then WScript.Echo "Buchhaltung"
  231. Network.MapNetworkDrive LW_R,"\\SERVER02\BUCHHALTUNG"
  232. Network.MapNetworkDrive LW_Q,"\\SERVER02\ROTH"
  233. if Trace=1 then WScript.Echo "Laufwerke Buchhaltung verbunden"
  234. end if
  235. Batch="reg import \\SERVER04\WENDELSTEIN\SharedDocuments.reg"
  236. if Trace=1 then WScript.Echo Batch
  237. Aus=Shell.Run(Batch,0,true)
  238. end if
  239. if Instr(UserGroups,GR_FUERTH) then
  240. if Trace=1 then WScript.Echo "Fürth"
  241. Network.MapNetworkDrive LW_O,"\\SERVER05\FUERTH"
  242. Network.MapNetworkDrive LW_P,"\\SERVER05\BENUTZER\"&Network.Username
  243. if Trace=1 then WScript.Echo "Laufwerke verbunden"
  244. end if
  245. if (Machine<>SERVER1 and Machine<>SERVER2 and Machine<>SERVER3 and Machine<>SERVER01 and Machine<>SERVER02 and Machine<>SERVER03 and Machine<>SERVER04 and Machine<>SERVER05) then
  246. if Trace=1 then WScript.Echo "Kein Server"
  247. if Instr(UserGroups,GR_ROTH) then
  248. if Trace=1 then WScript.Echo "Drucker Roth ohne Server"
  249. Network.MapNetworkDrive LW_T,"\\SERVER02\THEORG"
  250. if Instr(UserGroups,PR_RH_EMPFANG) then
  251. if Trace=1 then WScript.Echo "Drucker Empfang"
  252. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  253. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  254. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  255. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  256. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  257. Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  258. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG_Fach1"
  259. if Trace=1 then WScript.Echo "Drucker Roth Empfang verbunden"
  260. end if
  261. if Instr(UserGroups,PR_RH_MTT) then
  262. if Machine=PC_TRAINING1 then
  263. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG"
  264. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG_Fach1"
  265. else
  266. Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  267. Network.SetDefaultPrinter "\\SERVER02\RH-MTT"
  268. end if
  269. if Trace=1 then WScript.Echo "Drucker MTT verbunden"
  270. end if
  271. if Instr(UserGroups,PR_RH_ERGO) then
  272. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  273. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  274. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  275. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  276. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  277. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG_Fach1"
  278. if Trace=1 then WScript.Echo "Drucker Ergo verbunden"
  279. end if
  280. if Instr(UserGroups,PR_RH_PHYSIO) then
  281. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  282. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  283. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  284. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  285. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  286. Network.AddWindowsPrinterConnection "\\SERVER02\RH-PHYSIO"
  287. Network.SetDefaultPrinter "\\SERVER02\RH-PHYSIO"
  288. if Trace=1 then WScript.Echo "Drucker Physio verbunden"
  289. end if
  290. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  291. if Ergebnis=IP_Roth then
  292. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  293. if Machine<>PC_ALBRECHT then
  294. Network.SetDefaultPrinter "\\SERVER02\RH-ABRECHNUNG"
  295. end if
  296. if Trace=1 then WScript.Echo "Drucker Abrechnung Roth in Roth"
  297. end if
  298. end if
  299. if Instr(UserGroups,PR_RH_CHEFS) then
  300. if Ergebnis=IP_Roth then
  301. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  302. if Trace=1 then WScript.Echo "Drucker Chefs Roth in Roth"
  303. end if
  304. end if
  305. end if
  306. if Instr(UserGroups,GR_WENDELSTEIN) then
  307. if Trace=1 then WScript.Echo "Wendelstein"
  308. Network.MapNetworkDrive LW_T,"\\SERVER04\THEORG"
  309. if Instr(UserGroups,PR_WE_EMPFANG) then
  310. Network.AddWindowsPrinterConnection "\\SERVER04\WE-EMPFANG"
  311. Network.AddWindowsPrinterConnection "\\SERVER04\WE-PLANUNG"
  312. Network.SetDefaultPrinter "\\SERVER04\WE-EMPFANG"
  313. if Trace=1 then WScript.Echo "Drucker Wendelstein Empfang verbunden"
  314. end if
  315. if Instr(UserGroups,PR_WE_PLANUNG) then
  316. Network.AddWindowsPrinterConnection "\\SERVER04\WE-EMPFANG"
  317. Network.AddWindowsPrinterConnection "\\SERVER04\WE-PLANUNG"
  318. Network.SetDefaultPrinter "\\SERVER04\WE-PLANUNG"
  319. if Trace=1 then WScript.Echo "Drucker Planung verbunden"
  320. end if
  321. if Instr(UserGroups,PR_WE_ABRECHNUNG) or Instr(UserGroups,PR_RH_ABRECHNUNG) then
  322. if Ergebnis=IP_Wendelstein then
  323. Network.AddWindowsPrinterConnection "\\SERVER04\WE-PLANUNG"
  324. Network.SetDefaultPrinter "\\SERVER04\WE-PLANUNG"
  325. if Trace=1 then WScript.Echo "Drucker Planung Wendelstein in Wendelstein"
  326. end if
  327. if Ergebnis=IP_Roth then
  328. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  329. Network.SetDefaultPrinter "\\SERVER02\RH-ABRECHNUNG"
  330. if Trace=1 then WScript.Echo "Drucker Abrechnung Wendelstein in Roth"
  331. end if
  332. end if
  333. end if
  334. if Instr(UserGroups,GR_FUERTH) then
  335. if Trace=1 then WScript.Echo "Fürth"
  336. Network.MapNetworkDrive LW_T,"\\SERVER05\THEORG"
  337. if Machine=PC_KRUL then
  338. Network.AddWindowsPrinterConnection "\\ALPHA140214\EK-MFC7321"
  339. Network.SetDefaultPrinter "\\ALPHA140214\EK-MFC7321"
  340. end if
  341. end if
  342. else
  343. if Trace=1 then WScript.Echo "Am Server " & Ergebnis2
  344. if Trace=1 then WScript.Echo Machine
  345. if Machine=SERVER02 then
  346. if Instr(UserGroups,GR_ROTH) then
  347. if Trace=1 then WScript.Echo "Drucker Roth am TS in Roth für Gruppe Roth"
  348. Network.MapNetworkDrive LW_T,"\\SERVER02\THEORG"
  349. if Instr(UserGroups,PR_RH_EMPFANG) then
  350. Network.SetDefaultPrinter "RH-EMPFANG"
  351. if Trace=1 then WScript.Echo "Drucker RH-Empfang am Server02 für RH-Empfang verbunden"
  352. end if
  353. if Instr(UserGroups,PR_RH_MTT) then
  354. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  355. Network.SetDefaultPrinter "RH-MTT"
  356. if Trace=1 then WScript.Echo "Drucker RH-MTT am Server02 für RH-MTT verbunden"
  357. end if
  358. if Instr(UserGroups,PR_RH_ERGO) then
  359. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  360. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  361. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  362. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  363. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  364. Network.SetDefaultPrinter "RH-EMPFANG_Fach1"
  365. if Trace=1 then WScript.Echo "Drucker RH-Ergo am Server02 für RH-Ergo verbunden"
  366. end if
  367. if Instr(UserGroups,PR_RH_PHYSIO) then
  368. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG"
  369. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-PHYSIO"
  370. Network.SetDefaultPrinter "RH-PHYSIO"
  371. if Trace=1 then WScript.Echo "Drucker RH-Physio am Server02 für RH-Physio verbunden"
  372. end if
  373. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  374. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  375. Network.SetDefaultPrinter "RH-ABRECHNUNG"
  376. if Trace=1 then WScript.Echo "Drucker RH-Abrechnung am Server02 für RH-Abrechnung verbunden"
  377. end if
  378. end if
  379. if Instr(UserGroups,GR_WENDELSTEIN) then
  380. if Trace=1 then WScript.Echo "Drucker Roth am TS in Roth für Gruppe Wendelstein"
  381. Network.MapNetworkDrive LW_T,"\\SERVER02\THEORG"
  382. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  383. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  384. 'Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  385. Network.SetDefaultPrinter "RH-ABRECHNUNG"
  386. if Trace=1 then WScript.Echo "Drucker RH-Abrechnung am Server02 für RH-Abrechnung verbunden"
  387. end if
  388. end if
  389. if (UserName<>US_Administrator) then
  390. Batch="Taskkill /FI " & CHR(34) & "USERNAME eq " & LoginName & CHR(34) & " /IM explorer.exe /F"
  391. if Trace=1 then WScript.Echo Batch
  392. Ergebnis=Shell.Run(Batch,0,true)
  393. Batch="T:\START.BAT"
  394. Ergebnis=Shell.Run(Batch,0,true)
  395. if Trace=1 then WScript.Echo "Hab' gewartet!"
  396. Batch="shutdown /l /f"
  397. Ergebnis=Shell.Run(Batch,0,true)
  398. end if
  399. end if
  400. if Machine=SERVER04 then
  401. if Instr(UserGroups,GR_ROTH) then
  402. if Trace=1 then WScript.Echo "Drucker Roth am TS in Wendelstein für Gruppe Roth"
  403. Network.MapNetworkDrive LW_T,"\\SERVER04\THEORG"
  404. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  405. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  406. Network.AddWindowsPrinterConnection "\\SERVER02\RH-REZEPTE"
  407. Network.SetDefaultPrinter "\\SERVER02\RH-ABRECHNUNG"
  408. if Trace=1 then WScript.Echo "Drucker RH-Abrechnung am Server04 für RH-Abrechnung verbunden"
  409. end if
  410. end if
  411. if Instr(UserGroups,GR_WENDELSTEIN) then
  412. if Trace=1 then WScript.Echo "Drucker Wendelstein am TS in Wendelstein für Gruppe Wendelstein"
  413. Network.MapNetworkDrive LW_T,"\\SERVER04\THEORG"
  414. if Instr(UserGroups,PR_WE_PLANUNG) then
  415. 'Network.AddWindowsPrinterConnection "\\SERVER04\WE-PLANUNG"
  416. 'Network.AddWindowsPrinterConnection "\\SERVER04\WE-EMPFANG"
  417. Network.SetDefaultPrinter "WE-PLANUNG"
  418. if Trace=1 then WScript.Echo "Drucker WE-Planung am Server04 für WE-Planung verbunden"
  419. end if
  420. if Instr(UserGroups,PR_WE_EMPFANG) then
  421. 'Network.AddWindowsPrinterConnection "\\SERVER04\WE-EMPFANG"
  422. Network.SetDefaultPrinter "WE-EMPFANG"
  423. if Trace=1 then WScript.Echo "Drucker WE-Empfang am Server04 für WE-Empfang verbunden"
  424. end if
  425. end if
  426. if (UserName<>US_Administrator) then
  427. Batch="Taskkill /FI " & CHR(34) & "USERNAME eq " & LoginName & CHR(34) & " /IM explorer.exe /F"
  428. if Trace=1 then WScript.Echo Batch
  429. Ergebnis=Shell.Run(Batch,0,true)
  430. Batch="T:\START.BAT"
  431. Ergebnis=Shell.Run(Batch,0,true)
  432. if Trace=1 then WScript.Echo "Hab' gewartet!"
  433. Batch="shutdown /l /f"
  434. Ergebnis=Shell.Run(Batch,0,true)
  435. end if
  436. end if
  437.  
  438. if Machine<>SERVER02 and Machine<>SERVER04 then
  439. Set WTS = Wscript.CreateObject("WTSManager.Shell")
  440. '------------------------------------------------------
  441. '----------- IP Adresse des TS-Clients ermitteln ------
  442. TSIp=WTS.MyIPAddress
  443. Ergebnis2=TSIp
  444. if Trace=1 then Wscript.Echo ("IP Adresse : " & Ergebnis2)
  445. if Ergebnis2<>"" then
  446. if Trace=1 then Wscript.Echo "IPAdresse der TS Clients:" & Ergebnis2
  447. a1=instr(Ergebnis2,".")
  448. a2=instr(a1+1,Ergebnis2,".")
  449. a3=instr(a2+1,Ergebnis2,".")
  450. Ergebnis1=left(Ergebnis2,a2)
  451. if Ergebnis1="192.168." then
  452. OwnTSIP=mid(Ergebnis2,a2+1,a3-a2-1)
  453. if Trace=1 then Wscript.Echo ("Duooktett : " & Ergebnis1)
  454. end if
  455. End if
  456. Ergebnis2=OwnTSIP
  457. if Trace=1 then WScript.Echo "TSIPNetz: " & Ergebnis2
  458. '- In Roth -------------------------------------------------------------------
  459. if Ergebnis2=IP_Roth then
  460. if Trace=1 then WScript.Echo "TS Client in Roth"
  461. '- Alpha03 -------------------------------------------------------------------
  462. if Machine=SERVER2 or Machine=SERVER02 then
  463. if Trace=1 then WScript.Echo "Drucker Roth am Server Alpha03"
  464. Network.MapNetworkDrive LW_T,"\\SERVER02\THEORG"
  465. if Instr(UserGroups,PR_RH_EMPFANG) then
  466. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  467. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  468. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  469. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  470. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  471. Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  472. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG_Fach1"
  473. if Trace=1 then WScript.Echo "Drucker RH-Empfang am Server Alpha03 für RH-Empfang verbunden"
  474. end if
  475. if Instr(UserGroups,PR_RH_MTT) then
  476. Network.AddWindowsPrinterConnection "\\SERVER02\RH-MTT"
  477. Network.SetDefaultPrinter "\\SERVER012RH-MTT"
  478. if Trace=1 then WScript.Echo "Drucker RH-MTT am Server Alpha03 für RH-MTT verbunden"
  479. end if
  480. if Instr(UserGroups,PR_RH_ERGO) then
  481. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  482. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  483. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  484. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  485. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  486. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG_Fach1"
  487. if Trace=1 then WScript.Echo "Drucker RH-Ergo am Server Alpha03 für RH-Ergo verbunden"
  488. end if
  489. if Instr(UserGroups,PR_RH_PHYSIO) then
  490. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach1"
  491. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach2(A5)"
  492. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach3"
  493. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_Fach4"
  494. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG_A6"
  495. Network.AddWindowsPrinterConnection "\\SERVER02\RH-PHYSIO"
  496. Network.SetDefaultPrinter "\\SERVER02\RH-PHYSIO"
  497. if Trace=1 then WScript.Echo "Drucker RH-Physio am Server Alpha03 für RH-Physio verbunden"
  498. end if
  499. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  500. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  501. Network.SetDefaultPrinter "\\SERVER02\RH-ABRECHNUNG"
  502. if Trace=1 then WScript.Echo "Drucker RH-Abrechnung am Server Alpha03 für RH-Abrechnung verbunden"
  503. end if
  504. end if
  505. '- Alpha01 -------------------------------------------------------------------
  506. if Machine=SERVER1 then
  507. if Trace=1 then WScript.Echo "Drucker Roth am Server Alpha01"
  508. Network.MapNetworkDrive LW_T,"\\SERVER04\THEORG"
  509. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  510. Network.AddWindowsPrinterConnection "\\SERVER02\RH-ABRECHNUNG"
  511. Network.AddWindowsPrinterConnection "\\SERVER02\RH-REZEPTE"
  512. Network.SetDefaultPrinter "\\SERVER02\RH-ABRECHNUNG"
  513. if Trace=1 then WScript.Echo "Drucker RH-Abrechnung am Server Alpha01 für RH-Abrechnung verbunden"
  514. end if
  515. if Instr(UserGroups,PR_RH_EMPFANG) then
  516. Network.AddWindowsPrinterConnection "\\SERVER02\RH-EMPFANG"
  517. Network.SetDefaultPrinter "\\SERVER02\RH-EMPFANG"
  518. if Trace=1 then WScript.Echo "Drucker RH-Empfang am Server Alpha03 für RH-Empfang verbunden"
  519. end if
  520. end if
  521. end if
  522. '- In Wendelstein ------------------------------------------------------------
  523. if Ergebnis2=IP_Wendelstein then
  524. if Trace=1 then WScript.Echo "TS Client in Wendelstein"
  525. '- Alpha01 -------------------------------------------------------------------
  526. if Machine=SERVER1 then
  527. if Trace=1 then WScript.Echo "Drucker Wendelstein am Server Alpha01"
  528. Network.MapNetworkDrive LW_T,"\\SERVER04\THEORG"
  529. if Instr(UserGroups,PR_WE_EMPFANG) then
  530. Network.SetDefaultPrinter "WE-EMPFANG"
  531. if Trace=1 then WScript.Echo "Drucker WE-Empfang am Server Alpha01 für WE-Empfang verbunden"
  532. end if
  533. if Instr(UserGroups,PR_WE_PLANUNG) then
  534. Network.SetDefaultPrinter "WE-PLANUNGSBUERO"
  535. if Trace=1 then WScript.Echo "Drucker WE-Planung am Server Alpha01 für WE-Planungsbüro verbunden"
  536. end if
  537. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  538. Network.SetDefaultPrinter "WE-ABRECHNUNG"
  539. if Trace=1 then WScript.Echo "Drucker WE-Abrechnung am Server Alpha01 für RH-Abrechnung verbunden"
  540. end if
  541. end if
  542. '- Alpha03 -------------------------------------------------------------------
  543. if Machine=SERVER2 or Machine=SERVER02 then
  544. if Trace=1 then WScript.Echo "Drucker Wendelstein am Server Alpha03"
  545. Network.MapNetworkDrive LW_T,"\\Alpha03\Theorg"
  546. if Instr(UserGroups,PR_WE_ABRECHNUNG) then
  547. 'Network.AddWindowsPrinterConnection "\\ALPHA01\WE-ABRECHNUNG"
  548. Network.SetDefaultPrinter "WE-ABRECHNUNG"
  549. if Trace=1 then WScript.Echo "Drucker WE-Abrechnung am Server Alpha03 für WE-Abrechnung verbunden"
  550. end if
  551. if Instr(UserGroups,PR_RH_ABRECHNUNG) then
  552. Network.AddWindowsPrinterConnection "\\ALPHA01\WE-ABRECHNUNG"
  553. Network.SetDefaultPrinter "\\ALPHA01\WE-ABRECHNUNG"
  554. if Trace=1 then WScript.Echo "Drucker WE-Abrechnung am Server Alpha03 für RH-Abrechnung verbunden"
  555. end if
  556. if Instr(UserGroups,PR_WE_EMPFANG) then
  557. Network.AddWindowsPrinterConnection "\\ALPHA01\WE-EMPFANG"
  558. Network.SetDefaultPrinter "\\ALPHA01\WE-EMPFANG"
  559. if Trace=1 then WScript.Echo "Drucker WE-Wendelstein am Server Alpha03 für WE-Empfang verbunden"
  560. end if
  561. end if
  562. '- Alpha02 -------------------------------------------------------------------
  563. if Machine=SERVER3 then
  564. if Trace=1 then WScript.Echo "Drucker Wendelstein am Server Alpha02"
  565. Network.MapNetworkDrive LW_T,"\\ALPHA02\THEORG"
  566. if Instr(UserGroups,PR_WE_ABRECHNUNG) then
  567. Network.AddWindowsPrinterConnection "\\ALPHA01\WE-ABRECHNUNG"
  568. Network.SetDefaultPrinter "\\ALPHA01\WE-ABRECHNUNG"
  569. if Trace=1 then WScript.Echo "Drucker WE-Abrechnung am Server Alpha02 für WE-Abrechnung verbunden"
  570. end if
  571. end if
  572. end if
  573. '- In Fürth --------------------------------------------------------------
  574. if Machine=SERVER05 then
  575. if Trace=1 then WScript.Echo "TS Client in Fürth"
  576. '- Server05 -------------------------------------------------------------------
  577. if Machine=SERVER05 and UserName<>US_Administrator then
  578. if Trace=1 then WScript.Echo "Fürth am Server Server05"
  579. Network.MapNetworkDrive LW_T,"\\SERVER05\THEORG"
  580. if UserName=US_HMUELLER then
  581. if Trace=1 then WScript.Echo "Drucker für AP H.Müller"
  582. Network.AddWindowsPrinterConnection "\\ALPHA150214\HM-HL2140"
  583. Network.SetDefaultPrinter "\\ALPHA150214\HM-HL2140"
  584. end if
  585. if UserName=US_EKRUL then
  586. if Trace=1 then WScript.Echo "Drucker für AP E.Krul"
  587. Network.AddWindowsPrinterConnection "\\ALPHA140214\EK-MFC7321"
  588. Network.SetDefaultPrinter "\\ALPHA140214\EK-MFC7321"
  589. end if
  590. if UserName=US_HBAUMGAERTEL then
  591. if Trace=1 then WScript.Echo "Drucker für AP H.Baumgärtel"
  592. Network.AddWindowsPrinterConnection "\\ALPHA130214\HB-HL2140"
  593. Network.SetDefaultPrinter "\\ALPHA130214\HB-HL21401"
  594. end if
  595. end if
  596. end if
  597. if (UserName<>US_Administrator) then
  598. Batch="Taskkill /FI " & CHR(34) & "USERNAME eq " & LoginName & CHR(34) & " /IM explorer.exe /F"
  599. if Trace=1 then WScript.Echo Batch
  600. Ergebnis=Shell.Run(Batch,0,true)
  601. Batch="T:\START.BAT"
  602. Ergebnis=Shell.Run(Batch,0,true)
  603. end if
  604. end if
  605. end if
  606. if Trace=1 then WScript.Echo "Login Script beendet"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement