Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. (new-object System.Net.WebClient).DownloadFile('https://pbs.twimg.com/media/DvSImELUcAE31OH.jpg',"$Env:Temp\b.jpg");
  2.  
  3. Add-Type @"
  4.  
  5. using System;
  6.  
  7. using System.Runtime.InteropServices;
  8.  
  9. using Microsoft.Win32;
  10.  
  11. namespace Wallpaper
  12.  
  13. {
  14. public enum Style : int
  15. {
  16.  
  17. Tile, Center, Stretch, NoChange
  18. } public class Setter {
  19.  
  20. public const int SetDesktopWallpaper = 20;
  21.  
  22. public const int UpdateIniFile = 0x01;
  23.  
  24. public const int SendWinIniChange = 0x02;
  25.  
  26. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
  27.  
  28. private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni);
  29.  
  30. public static void SetWallpaper ( string path, Wallpaper.Style style ) {
  31.  
  32. SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange );
  33.  
  34. RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
  35.  
  36. switch( style )
  37.  
  38. {
  39.  
  40. case Style.Stretch :
  41.  
  42. key.SetValue(@"WallpaperStyle", "2") ;
  43.  
  44. key.SetValue(@"TileWallpaper", "0") ;
  45.  
  46. break;
  47.  
  48. case Style.Center :
  49.  
  50. key.SetValue(@"WallpaperStyle", "1") ;
  51.  
  52. key.SetValue(@"TileWallpaper", "0") ;
  53.  
  54. break;
  55.  
  56. case Style.Tile :
  57.  
  58. key.SetValue(@"WallpaperStyle", "1") ;
  59.  
  60. key.SetValue(@"TileWallpaper", "1") ;
  61.  
  62. break;
  63.  
  64. case Style.NoChange :
  65.  
  66. break;
  67. }
  68.  
  69. key.Close();
  70.  
  71. }
  72. }
  73.  
  74. }
  75.  
  76. "@
  77.  
  78. [Wallpaper.Setter]::SetWallpaper("$Env:Temp\b.jpg" , 2 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement