Skip to content

Instantly share code, notes, and snippets.

@superlayone
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save superlayone/6a2bb97193cc0f19ffa7 to your computer and use it in GitHub Desktop.

Select an option

Save superlayone/6a2bb97193cc0f19ffa7 to your computer and use it in GitHub Desktop.
Add UAC and Set Hostname UUID

Add UAC and Set Hostname UUID

标签(空格分隔): UAC Hostname UniqueName


####This code snap add a UAC privilege to .bat files

REM This batfile just add a UAC auth to .bat
reg add "HKEY_CLASSES_ROOT\batfile\shell\open" /v HasLUAShield /t REG_SZ

####This code snap firstly generates an alphanumeric string in length 14,indicating an unique host in WLAN.The first character is W that represents a Windows machine.The remains choose randomly from CHARS string.After this step,we modify the registry and need a restart action,so just shutdown -r -t 0

@echo off
REM This is a random alpha-num generator
REM This script generates a string of these characters at least
REM You can change the CHAR_LENGTH TO generates other alpha-nums

SET CHARS=abcdefghijklmnopqrstuvwxyz0123456789
SET /A CHAR_LENGTH=26+10
SET /A ALPHA_LENGTH=14
SET HOSTNAME=W

SetLocal EnableDelayedExpansion

SET LINE=
FOR /L %%a in (1 1 %ALPHA_LENGTH%) do (
    SET /A CHAR_INDEX=!random! %% %CHAR_LENGTH%
    CALL SET EXTRACTED_CHAR=%%CHARS:~!CHAR_INDEX!,1%%
    SET LINE=!LINE!!EXTRACTED_CHAR!
)

SET HOSTNAME=%HOSTNAME%%LINE%

reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %HOSTNAME% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName" /v ComputerName /t reg_sz /d %HOSTNAME% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %HOSTNAME% /f 
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %HOSTNAME% /f  

REM Now restart
shutdown -r -t 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment