Registry Project

fedora

Distinguished
Feb 17, 2011
18
0
18,510
So i had an idea to bind a key combination on my keyboard to put my ip address in the clipboard but im not even certain its possible so i wanted some input. I figure the most direct way would be to edit the key mapping in the registry to run a bat file when i press a combination of keys and the bat would then copy my ip to the clipboard. Its a pretty stupid idea i know cus its easy to get your ip but i think it would be a cool project. Thoughts?
 

fedora

Distinguished
Feb 17, 2011
18
0
18,510
I do a lot of server management for different games and such and it would come in handy. Other than that, no real reason, i just thought it might be kinda cool. dont really care that much
 
You can do this with just a few lines in PowerShell:

$Adapters = Get-WMIObject Win32_NetworkAdapterConfiguration
$IPAddress = @(@($adapters | where { $_.IPEnabled -eq $True -and $_.DNSDomain -ne $null })[0].IPAddress)[0]
if ($IPAddress -ne $Null) { $IPAddress | Clip }

If you put the above three lines into a file called "Paste-IPAddress.ps1" you can create a shortcut to the file with a command line of:

PowerShell Paste-IPAddress.ps1

You'll have to add the path in front of the script name if the script file is not in one of the folders listed in the PATH environment variable.

If you're a server manager then IMHO you can't afford NOT to learn PowerShell...