Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.90 KB | None | 0 0
  1. rem clear the variable before we begin the test
  2. SET WKNAME=
  3. CLS
  4. REM this command will retrieve the value of a registry key from a target:
  5.  
  6. reg query \\127.0.0.1\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName
  7.  
  8. PAUSE
  9. CLS
  10.  
  11.  
  12. REM this command will retrieve the value of a registry key and then filter it to make it one line with three values
  13.  
  14. reg query \\127.0.0.1\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName | FIND "REG_SZ"
  15.  
  16. PAUSE
  17. CLS
  18.  
  19.  
  20. REM this command SHOULD retrieve the value of a registry key, filter it to make it one line with three values
  21. REM THEN it should retrieve the third value and put it into the variable "WKNAME"
  22.  
  23. FOR /F "tokens=3 delims= " %%A IN ('reg query \\127.0.0.1\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName ^|FIND "REG_SZ"') DO SET WKNAME=%%A
  24.  
  25. ECHO REG Name is: %WKNAME%
  26.  
  27. PAUSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement