Quantcast
Channel: Code, Snippets & Scripts – DevAdmin Blog
Viewing all articles
Browse latest Browse all 91

Script VBS per creazione collegamento a Dispositivi e stampanti

$
0
0

A volte può essere comodo creare sul desktop degli utenti un collegamento ad una funzionalità di uso frequente. Di seguito uno script VBS per creare un collegamento a Dispositivi e stampanti in Windows 7 e successivi:

Set WshShell = CreateObject(“WScript.Shell”)
strDesktop = WshShell.SpecialFolders(“Desktop”)
Set oLink = WshShell.CreateShortcut(strDesktop + “\Dispositivi e stampanti.lnk”)
oLink.TargetPath = “control.exe”
oLink.Arguments = “printers”
oLink.IconLocation = “devicecenter.dll, 0″
oLink.Save

Se si intende creare il collegamento nel desktop di tutti gli utenti è possibile modificare la riga (in questo caso l script andrà eseguito coi privilegi di amministratore locale):

strDesktop = WshShell.SpecialFolders(“Desktop”)

in

strDesktop = WshShell.SpecialFolders(“AllUsersDesktop”)

Per Windows XP l’icona da utilizzare quella di Stampanti e fax che sui trova in shell32.dll, quindi occorre modificare la riga:

oLink.IconLocation = “devicecenter.dll, 0″

in

oLink.IconLocation = “shell32.dll, 58″

Per maggiori informazioni si veda How to create a desktop shortcut with the Windows Script Host.

Ovviamente è possibile creare un collegamento in modo automatizzato anche tramite PowerShell, a riguardo si veda Hey, Scripting Guy! How Can I Add a Windows PowerShell Shortcut to the Quick Launch Toolbar? e The Easy Way to Use PowerShell to Work with Special Folders, in ogni caso viene sempre utilizzato l’oggetto COM WScript.Shell.

Tramite PowerShell lo script può essere riscritto come segue:

$wshshell = new-object -comobject wscript.shell
$desktop = [environment]::getfolderpath("Desktop")
$shortCutPath = join-path -path $desktop -childPath "Dispositivi e stampanti.lnk"
$shortCut = $wshShell.CreateShortCut($shortCutPath)
$shortCut.TargetPath = "control.exe"
$shortCut.Arguments = "printers"
$shortCut.IconLocation = "devicecenter.dll, 0"
$shortCut.Save()

Viewing all articles
Browse latest Browse all 91

Trending Articles


Henry el monstruo feliz para colorear e imprimir


Vimeo Create - Video Maker & Editor 1.4.0 by Vimeo Inc


Girasoles para colorear


Dibujos de animales para imprimir


Tropa Quotes


RE: Mutton Pies (frankie241)


Hagibis (1946) by Francisco V. Coching


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


UPDATE SC IDOL: TWO BECOME ONE


FORTUITOUS EVENT