[VBS] How to create a shortcut for Network Diagnostics with Hotkey


By: Hackoo
June 10, 2020

Hi everyone !
I want to share with you my vbscript in order to create a shortcut on the desktop for Network Diagnostics in order to fix internet connection and Networking issues.

How to use this vbscript ?

Just open your Notepad or Notepad++ and copy and paste this code below and save it as : Network_Diagnostics.vbs and run it by double click, so you will get a shortcut on your desktop for running Network Diagnostics in order to fix some issues that can be encountred when trying to connect to the internet !
NB : You can also run this tool with this hotkey combination : CTRL+ALT+D

Network_Diagnostics.vbs

Option Explicit
' Vbscript Created by Hackoo on 09/06/2020 @16:00
' Tested only on Windows 10 (32 bits)
' 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
'-------------------------------------------------------------------------------------------------------------------

For any update of this vbscript you will find it here


Need more help?
Describe your Problem
Example: Hard Drive Not Detected on My PC

Ask Question