Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
- $arguments = "& '" + $myinvocation.mycommand.definition + "'"
- Start-Process powershell -Verb runAs -ArgumentList $arguments
- Break
- }
- $buf = New-Object System.Byte[] 4096
- $socket = New-Object System.Net.Sockets.TcpClient("localhost", 3636)
- $stream = $socket.GetStream()
- $stream.Read($buf, 0, 4096)
- $msg = [System.Text.Encoding]::ASCII.GetBytes("apikey:`r`n")
- $stream.Write($msg, 0, $msg.Length)
- $stream.Read($buf, 0, 4096)
- $msg = [System.Text.Encoding]::ASCII.GetBytes("lock`r`n")
- $stream.Write($msg, 0, $msg.Length)
- $stream.Read($buf, 0, 4096)
- If ((Get-Service uxsms).Status -eq "Running") {
- Stop-Service uxsms;
- $msg = [System.Text.Encoding]::ASCII.GetBytes("setprofile:Multimedia`r`n")
- } else {
- Start-Service uxsms;
- $msg = [System.Text.Encoding]::ASCII.GetBytes("setprofile:Low profile`r`n")
- }
- $stream.Write($msg, 0, $msg.Length)
- $stream.Read($buf, 0, 4096)
- $msg = [System.Text.Encoding]::ASCII.GetBytes("unlock`r`n")
- $stream.Write($msg, 0, $msg.Length)
- $stream.Read($buf, 0, 4096)
- $msg = [System.Text.Encoding]::ASCII.GetBytes("exit`r`n")
- $stream.Write($msg, 0, $msg.Length)
- $stream.Read($buf, 0, 4096)
- $stream.Close()
- $socket.Close()
Advertisement
Add Comment
Please, Sign In to add comment