Files
THE-TOOL/CMD/SCCMAuf.bat
2025-12-14 15:46:14 +01:00

138 lines
4.3 KiB
Batchfile
Raw Permalink Blame History

@echo off
chpc 1252
title SMMC FQDN Vervollst„ndigung
:start
cls
COLOR 0f
echo ***************************************************************************
echo *****************************************************************************
echo ***** *****
echo ***** SCCM FQDN vervollst„ndigung *****
echo ***** *****
echo *****************************************************************************
echo ***************************************************************************
echo.
echo.
echo.
Echo Return f<>r Eingabe.
pause
cls
:: Set variable for InputBox:
set myMessage=Bitte ClientID / IP eingeben.
set myTitle=Bitte ClientID / IP eingeben
:: call :subInputBox
:: Gross Kleinschreibung Berichtigung
set RemoteHost=%RemoteHost:a=A%
set RemoteHost=%RemoteHost:i=I%
set RemoteHost=%RemoteHost:n=N%
::AbfrageIP
IF "%namez:~,1%" == "A" goto norm
echo.
echo.
set FQDN=%RemoteHost%
echo ClientID %FQDN%
goto :expl
::Abfrage ab nur ClientID
:norm
IF "%RemoteHost:~,1%" == "A" GOTO bmmf
:: Wenn fehlend ClientID, ergänzen
set /p stand=1 Ingolstadt oder 2 Neckasulm:
IF "%stand%"=="1" (set standz=IN)
IF "%stand%"=="2" (set standz=NE)
set /p client=1 Laptop 2 Festrechner 3 HILs:
IF "%client%"=="1" (set clientz=L)
IF "%client%"=="2" (set clientz=C)
IF "%client%"=="3" (set clientz=W)
set FQDN=AUDI%standz%%clientz%%RemoteHost%.%standz%.audi.vwg
goto expl
:: Restlichen FQDN NE oder IN auswerten
:bmmf
set namez=%RemoteHost:~4,1%
IF "%namez:~,1%" == "N" (set standz=NE)
IF "%namez:~,1%" == "I" (set standz=IN)
set FQDN=%RemoteHost%.%standz%.audi.vwg
goto expl
:: PING test
:expl
echo.
echo.
echo Ping Test
ping %FQDN% -n 1 | find "TTL"
IF NOT %ERRORLEVEL%==0 echo ***** ACHTUNG: Rechner konnte nicht angepingt werden
IF NOT %ERRORLEVEL%==0 pause
IF NOT %ERRORLEVEL%==0 goto start
:: Ausf<73>hrung
echo.
echo.
echo.
echo AUSF<53>HRUNG auf %FQDN%
echo.
\\audi.vwg\NETLOGON\ARS\CmRcViewer.exe %FQDN% \\SCCM
if %ERRORLEVEL% == 0 goto ende
goto errfehler
:errfehler
echo ***************************************************************************
echo *****************************************************************************
echo ***** *****
echo ***** Ausf<73>hrung FEHLER ... *****
echo ***** *****
echo *****************************************************************************
echo ***************************************************************************
color 0c
goto farbegesetzt
:ende
echo ***************************************************************************
echo *****************************************************************************
echo ***** *****
echo ***** Ausf<73>hrung erfolgreich ... *****
echo ***** *****
echo *****************************************************************************
echo ***************************************************************************
color 02
goto farbegesetzt
:farbegesetzt
echo.
echo.
Pause
goto start
:: Start subroutine subInputBox
:subInputBox
set VBS="%Temp%\vbsInputBox.vbs"
set CMD="%Temp%\cmdVar.bat"
>> %VBS% echo Option Explicit
>> %VBS% echo Dim strText
>> %VBS% echo Dim objShell : Set objShell = CreateObject("Wscript.Shell")
>> %VBS% echo Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
>> %VBS% echo Dim objFile : Set objFile = objFSO.CreateTextFile(%CMD%)
:: Pass variable from batch to VBScript
>> %VBS% echo strText = InputBox("%myMessage%", "%myTitle%")
>> %VBS% echo if strText = vbNullString then
:: Create batch file
>> %VBS% echo objFile.WriteLine "@echo off"
>> %VBS% echo objFile.WriteLine "set flag=false"
>> %VBS% echo else
>> %VBS% echo objFile.WriteLine "@echo off"
:: Set variable in batch file
>> %VBS% echo objFile.WriteLine "set RemoteHost=" ^& strText
>> %VBS% echo end if
>> %VBS% echo objFile.Close
cscript %VBS% > NUL
call %CMD% > NUL
del %CMD%
del %VBS%
goto :EOF
:: End subroutine subInputBox