1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
<!--more-->// Скрипт для создания на рабочем столе ярлыков подключенных сетевых дисков и RDP-подключений a=new ShortCutter(); // Создать RDP-подключение на рабочем столе, в полноэкранном режиме, с автоопределением разрешения экрана // и текущей учетной записью пользователя. a.createrdpfile("Терминал-сервер 1",true,"auto","auto","tserver.avangard.local"); // Создать RDP-подключение в оконном режиме с разрешением 800x600 // с учетной записью "AVANGARD-P\Operator1" a.createrdpfile("Терминал Пенза",false,800,600,"tserver-p.avangard-p.local","AVANGARD-P\\Operator1"); // Создать ярлыки для сетевых дисков "M:" и "O:" на рабочем столе a.createshortcut("Документы сервер1","M:\\","C:\\WINDOWS\\system32\\SHELL32.dll",9); a.createshortcut("Документы сервер2","O:\\","C:\\WINDOWS\\system32\\SHELL32.dll",9); //==================== function ShortCutter() { this.createshortcut=createshortcut; this.createrdpfile=createrdpfile; this.WshShell=WScript.CreateObject("WScript.Shell"); this.fso=new ActiveXObject("Scripting.FileSystemObject"); this.WshNetwork = WScript.CreateObject("WScript.Network"); this.user=this.WshNetwork.UserDomain + "\\" + this.WshNetwork.UserName; this.QueryWMI=QueryWMI; function createshortcut(name,path,icondll,iconpos) { strDesktop = this.WshShell.SpecialFolders("Desktop"); fp=strDesktop + "\\"+name+".lnk" if (this.fso.FileExists(fp)) return; var oShellLink = this.WshShell.CreateShortcut(fp); oShellLink.TargetPath = path; oShellLink.WindowStyle = 1; oShellLink.IconLocation = icondll+ " , "+iconpos; oShellLink.Description = name; oShellLink.WorkingDirectory = strDesktop; oShellLink.Save(); } function createrdpfile(name,fullscreen,resx,resy,server,user) { var WQL="Select ScreenHeight,ScreenWidth from Win32_DesktopMonitor where Availability=3"; var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; var compname, username, password; var wmi_items; var SWBemlocator = new ActiveXObject("WbemScripting.SWbemLocator"); var objWMIService = SWBemlocator.ConnectServer("localhost","\\root\\CIMV2","",""); var wmi_items = objWMIService.ExecQuery(WQL,"WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly); var wmi_enum = new Enumerator(wmi_items); var wmi_item = wmi_enum.item(); if (resx=="auto") resx=wmi_item.ScreenWidth; if (resy=="auto") resy=wmi_item.ScreenHeight if (user == null) u=this.user; else u=user; if (fullscreen==true) sm=2; else sm=1; strDesktop = this.WshShell.SpecialFolders("Desktop"); fp=strDesktop + "\\"+name+".rdp" if (!this.fso.FileExists(fp)) { fo = this.fso.CreateTextFile(fp,true); s="screen mode id:i:1\n\ session bpp:i:16\n\ winposstr:s:0,0,0,0,"+resx+","+resy+"\n\ compression:i:1\n\ keyboardhook:i:2\n\ displayconnectionbar:i:1\n\ disable wallpaper:i:1\n\ disable full window drag:i:1\n\ allow desktop composition:i:0\n\ allow font smoothing:i:0\n\ disable menu anims:i:1\n\ disable themes:i:1\n\ disable cursor setting:i:0\n\ bitmapcachepersistenable:i:1\n\ audiomode:i:0\n\ redirectprinters:i:1\n\ redirectcomports:i:1\n\ redirectsmartcards:i:1\n\ redirectclipboard:i:1\n\ redirectposdevices:i:0\n\ autoreconnection enabled:i:1\n\ authentication level:i:0\n\ prompt for credentials:i:0\n\ negotiate security layer:i:1\n\ remoteapplicationmode:i:0\n\ alternate shell:s:\n\ shell working directory:s:\n\ gatewayhostname:s:\n\ gatewayusagemethod:i:4\n\ gatewaycredentialssource:i:4\n\ gatewayprofileusagemethod:i:0\n\ promptcredentialonce:i:1\n\ drivestoredirect:s:\n" s=s+"full address:s:"+server+ "\nusername:s:"+u+"\ndesktopwidth:i:"+resx+ "\ndesktopheight:i:"+resy+"\n"+ "screen mode id:i:"+sm+"\n"; fo.Write(s); fo.Close(); } delete wmi_enum; delete fso; delete SWBemlocator; } } |
скачать createshortcuts_129