Guest User

Untitled

a guest
Aug 17th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {  
  2.     $arguments = "& '" + $myinvocation.mycommand.definition + "'"
  3.     Start-Process powershell -Verb runAs -ArgumentList $arguments
  4.     Break
  5. }
  6.  
  7. $buf = New-Object System.Byte[] 4096
  8. $socket = New-Object System.Net.Sockets.TcpClient("localhost", 3636)
  9. $stream = $socket.GetStream()
  10. $stream.Read($buf, 0, 4096)
  11. $msg = [System.Text.Encoding]::ASCII.GetBytes("apikey:`r`n")
  12. $stream.Write($msg, 0, $msg.Length)
  13. $stream.Read($buf, 0, 4096)
  14. $msg = [System.Text.Encoding]::ASCII.GetBytes("lock`r`n")
  15. $stream.Write($msg, 0, $msg.Length)
  16. $stream.Read($buf, 0, 4096)
  17.  
  18. If ((Get-Service uxsms).Status -eq "Running") {
  19.     Stop-Service uxsms;
  20.     $msg = [System.Text.Encoding]::ASCII.GetBytes("setprofile:Multimedia`r`n")
  21. } else {
  22.     Start-Service uxsms;
  23.     $msg = [System.Text.Encoding]::ASCII.GetBytes("setprofile:Low profile`r`n")
  24. }
  25.  
  26. $stream.Write($msg, 0, $msg.Length)
  27. $stream.Read($buf, 0, 4096)
  28. $msg = [System.Text.Encoding]::ASCII.GetBytes("unlock`r`n")
  29. $stream.Write($msg, 0, $msg.Length)
  30. $stream.Read($buf, 0, 4096)
  31. $msg = [System.Text.Encoding]::ASCII.GetBytes("exit`r`n")
  32. $stream.Write($msg, 0, $msg.Length)
  33. $stream.Read($buf, 0, 4096)
  34. $stream.Close()
  35. $socket.Close()
Advertisement
Add Comment
Please, Sign In to add comment