Cogger

Note_Drop_IP_FQDN

Aug 19th, 2021 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Enum ShowStates
  2. {
  3.   Hide = 0
  4.   Normal = 1
  5.   Minimized = 2
  6.   Maximized = 3
  7.   ShowNoActivateRecentPosition = 4
  8.   Show = 5
  9.   MinimizeActivateNext = 6
  10.   MinimizeNoActivate = 7
  11.   ShowNoActivate = 8
  12.   Restore = 9
  13.   ShowDefault = 10
  14.   ForceMinimize = 11
  15. }
  16.  
  17. $V = Read-Host -Prompt 'Write in or paste the FQDN here'
  18. $ips = ([System.Net.Dns]::GetHostAddresses("$V")).IPAddressToString
  19. Start-Process 'notepad.exe'
  20. Sleep 1
  21. $wshell = New-Object -ComObject wscript.shell;
  22. $wshell.AppActivate('Untitled - Notepad')
  23. Sleep 1
  24. $wshell.SendKeys('FQDN:')
  25. $wshell.SendKeys('~')
  26. $wshell.SendKeys("$V")
  27. $wshell.SendKeys('~')
  28. $wshell.SendKeys('IP Address:')
  29. $wshell.SendKeys('~')
  30. $wshell.SendKeys("$ips") ; sleep 1
  31. $notePID = (Get-Process "notepad").Id
  32.  
  33. $code = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
  34. $type = Add-Type -MemberDefinition $code -Name myAPI -PassThru
  35. $process = Get-Process -Id $notePID
  36. $hwnd = $process.MainWindowHandle ; sleep 1
  37. $type::ShowWindowAsync($hwnd, [ShowStates]::Minimized)
Add Comment
Please, Sign In to add comment