question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked IanXue-MSFT commented

This script for VMManager Windows OS Template is true or not?

There is an OS template script for ISPSystem VMManager. It looks like this:

 @echo off
 setlocal EnableDelayedExpansion
    
 set logfile=C:\setup.log
    
 del /f c:\ifacename.txt
    
 for /f "skip=2 tokens=2,4*" %%A in ('netsh interface show interface') do (
   if "%%A" == "Connected" (
     echo %%B %%C>> c:\ifacename.txt
   )
 )
    
 set /P IFACENAME=< c:\ifacename.txt
    
 echo Trimming
    
 set IFACENAME=%IFACENAME%##
 set IFACENAME=%IFACENAME:    ##=##%
 set IFACENAME=%IFACENAME:  ##=##%
 set IFACENAME=%IFACENAME: ##=##%
 set IFACENAME=%IFACENAME:##=%
    
 del /f c:\ifacename.txt
    
 echo --- Interface name: %IFACENAME% >> %logfile%
    
 echo --- set Administartor password >> %logfile%
    
 net user Administrator ($PASS)  >> %logfile%
 echo ------Set static IP-------------------------------------[%DATE%-%TIME%]      > %logfile%
 echo --- IP/NM=($IP)/($NETMASK)  GW=($GATEWAY)      >> %logfile%
 echo --- NS1=($NAMESERVER)                                                   >> %logfile%
    
 set "nexthop=($NEXTHOPIPv4)"
    
 IF "%nexthop%"=="()" (
         set "nexthop=NONE"
 )
 echo %nexthop% | findstr /c:( 1>nul
 IF NOT ERRORLEVEL 1 (
         set "nexthop=NONE"
 )
    
 IF (%nexthop%) == () (
         set "nexthop=NONE"
 )
    
 if (%nexthop%) == (NONE) (
         netsh interface ip set address    "%IFACENAME%" static ($IP) ($NETMASK) ($GATEWAY)  >> %logfile%
 ) ELSE (
         netsh interface ip set address    "%IFACENAME%" static ($IP) 255.255.255.255 ($NEXTHOPIPv4)  >> %logfile%
 )
    
 netsh interface ip add dnsservers "%IFACENAME%" ($NAMESERVER)          >> %logfile%
    
 set "nslist=($NAMESERVERS)"
    
 IF "%nslist%"=="()" (
         set "nslist=NEX"
 )
 echo %nslist% | findstr /c:( 1>nul
 IF NOT ERRORLEVEL 1 (
         set "nslist=NEX"
 )
    
 if NOT "%nslist%"=="" ( 
         IF NOT "%nslist%"=="NEX" (
                 set flist=%nslist:"=%
                 echo NAMESERVERS: !flist! >> %logfile%
 REM                netsh interface ip delete dnsservers "%IFACENAME%" all >> %logfile%
                 FOR %%i IN (!flist!) DO (
                         echo %%i >> %logfile%
                         echo %%i | findstr /c:: 1>nul
                         if ERRORLEVEL 1 (
                                 echo ipv4 >> %logfile%
                                 netsh interface ip add dnsservers "%IFACENAME%" %%i >> %logfile%
                         ) ELSE (
                                 echo ipv6 >> %logfile%
                                 netsh interface ipv6 add dnsservers "Ethernet" %%i >> %logfile%
                         )
                 )
         ) ELSE (
                 echo BRACERS >> %logfile%
         )
 ) ELSE (
         echo EMPTY >> %logfile%
 )
    
 set extendfile=C:\vmmgr\extend.txt
 echo --- resize disk >> %logfile%
 echo select volume 1 > %extendfile%
 echo extend noerr >> %extendfile%
 diskpart.exe /s %extendfile% >> %logfile%
    
 set "pkey=($PRODUCTKEY)"
    
 IF NOT "%pkey%" == "" (
         IF NOT "%pkey%" == "()" (
                 echo "PKEY is not null. Activating license"
                 echo activate windows >> %logfile%
                 cscript %windir%\system32\slmgr.vbs -ipk %pkey%
                 cscript %windir%\system32\slmgr.vbs -ato
         ) ELSE (
                 echo "PKEY is bracers" >> %logfile%
         )
 ) ELSE (
         echo "PKEY is EMPTY" >> %logfile%
 )
    
 echo remove task vmmgr_firstrun >> %logfile%
 schtasks /Delete /TN "vmmgr_firstrun" /F  >> %logfile%
 echo restart OS >> %logfile%
 echo ------END--------------------------------------------------[%DATE%-%TIME%]     >> %logfile%
    
 REM Russian language
 REM echo $lang = "ru-RU" >> C:\vmmgr\lang.ps1
 REM echo $langpack = Get-ChildItem "C:\vmmgr\langs\*language*$lang.cab" >> \vmmgr\lang.ps1
 REM echo Dism /Online /Add-Package /PackagePath:"$langpack" >> C:\vmmgr\lang.ps1
 REM echo Set-WinSystemLocale $lang >> c:\vmmgr\lang.ps1
 REM echo Set-WinUILanguageOverride $lang >> c:\vmmgr\lang.ps1
 REM echo $oldList = Get-WinUserLanguageList >> c:\vmmgr\lang.ps1
 REM echo $oldList.Add($lang) >> c:\vmmgr\lang.ps1
 REM echo Set-WinUserLanguageList $oldList -force >> c:\vmmgr\lang.ps1
 REM powershell.exe c:\vmmgr\lang.ps1 >> %logfile%
    
 REM Enable RDP
 reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
 netsh firewall set service remotedesktop enable
    
 echo RMDIR /s /Q  C:\vmmgr >> c:\del.cmd
 echo shutdown /r >> c:\del.cmd
 cmd /c c:\del.cmd

This script is true or not?

windows-serverwindows-10-setupwindows-server-setup
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you help to clarify your issue? Does the script show any error message?

0 Votes 0 ·

0 Answers