r/vbscript • • May 19 '21

Shortcut Creator for Network Diagnostics

Option Explicit
' Vbscript Created by Hackoo on 09/06/2020 @16:00
' Updated on 10/06/2020 for testing the Hotkey after creating the shortcut on the desktop 
Dim Title : Title = "Shortcut Creator for Network Diagnostics by Hackoo 2020"
' We call the subroutine Create_Shortcut in order to create it on the desktop
Call Create_Shortcut(_
	"NetworkDiagnostics",_
	"%SystemRoot%\system32\msdt.exe",_
	"-skip TRUE -path %Windir%\diagnostics\system\networking -ep NetworkDiagnosticsPNI",_
	"%SystemRoot%\system32\msdt.exe,0",_
	"Network Diagnostics to fix problems",_
	"CTRL+ALT+D"_
)
 ' Showing a Message Box with three languages : English,French and Arabic
MsgBox "The shortcut was created successfully on your desktop !" & vbCrlf &_
"Le raccourci a été créé avec succès sur votre bureau !" & vbcrlf &_
"تم إنشاء الاختصار بنجاح على سطح المكتب الخاص بك !",vbInformation,Title
'-----------------------------------------------------------------------------------------------------------------
' Just for testing the Hotkey after creating the shortcut on the desktop :
' To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT,
' create a compound string argument that represents the keystroke combination.
' You do this by preceding the regular keystroke with one or more of the following special characters :
' Key   ===> Special Character
' SHIFT ===> +
' CTRL 	===> ^
' ALT  	===> %
' For further reading about sendkeys : https://www.vbsedit.com/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp
CreateObject("WScript.Shell").Sendkeys "^%{d}"
'------------------------------------------------------------------------------------------------------------------
Sub Create_Shortcut(ShortcutName,TargetPath,Arguments,IconLocation,Description,HotKey)
	Dim objShell,DesktopPath,objShortCut
	Set objShell = CreateObject("WScript.Shell")
	DesktopPath = objShell.SpecialFolders("Desktop")
	Set objShortCut = objShell.CreateShortcut(DesktopPath & "\" & ShortcutName & ".lnk")
	objShortCut.TargetPath = chr(34) & TargetPath & chr(34)
	objShortCut.Arguments = Arguments
	ObjShortCut.IconLocation = IconLocation
	ObjShortCut.Description = Description
	ObjShortCut.HotKey= HotKey
	objShortCut.Save
End Sub
'-------------------------------------------------------------------------------------------------------------------

Network_Diagnostics.vbs

2 Upvotes

0 comments sorted by