Category Archives: Howto Tutorials (EN)

Howto Tutorials English Contribution Howto’s and Tutorials unblog technical contribution for professionals

Create Shortcut using VBScript

Create shortcuts on desktop with Visual Basic Script

VBScripts can help wherever automated tasks need to be used. Batch files may not always be appropriate, and the use of Group Policy may not always be available, where a Visual Basic Script can do this, for example, to provide shortcuts to applications.


The following VBScript creates a shortcut on the desktop, here for example to open the Windows Calculator.

Insert VBScript lines by  Copy Paste into Notepad and save them as create-shortcut.vbs, then douple-click to execute the VBScript will create the shortcut on desktop.

Now double-clicking the shortcut on the desktop opens the Windows Calculator. This VBScript can be started with cscript from the command prompt or from a batch.

  Last but not least, enjoy to edit the Const lines in the script to use any other applications.

Network drive mapping from PowerShell Script

Mapping Windows Network Drive using PowerShell

PowerShell scripts can be used to create network drives to Windows network shares on servers or NAS devices. Where batch processing is not the right choice, or where Group Policy is not possible, a PowerShell script can perform this task, for example, when running login scripts with remote clients via VPN, or clients that are not members of the AD domain.

PS-Script for Network Drive Mapping

This PowerShell Script example netdrive.ps1, creates the Windows network mapping to drive Z: for a specific user, whereby you can log on as a different user than you are authenticated with on the client.

The corresponding Windows network share is defined in line 7 at $sharePath, and the drive is assigned in line 8 at $mapDrive, adjusting the respective placeholder between the quotation marks. If further network shares are to be mapped, in the if loop copy lines 7 – 11 for the next network share using the variables $sharePath1 and $mapDrive1.

Windows PowerShell Credentials
Windows PowerShell Credentials

Run PowerShell Script from Batch

If a batch is already in place, for example netlogon.bat, then execute netdrive.ps1 out from a batch file as follows:

After a successful logon, is it possible to check the network mapping, for this the processes are logged in the file netdrive.log.

Network drive mapping from VBScript

Mapping Windows Network Drive using Visual Basic Script

VBScript can be used to connect network drives to Windows shares on servers or NAS devices. In situations where batch processing is not the right choice, or group policy is not the application you want, a Visual Basic Script can meet the requirement, for example, to apply login scripts to VPN Remote Clients who are not members of the AD domain.

Microsoft VBScript contains object classes, methods (functions / procedures) and value structures. Our MapNetworkDrive object is used as a method here. The method or verb in turn manipulates values.

Any object can be used, the object objNetwork is defined here, script developers like to stick to patterns and their variables. A prefix of str indicates a string value, while the obj prefix indicates an object. After WScript has created our objNetwork, it can be edited using the MapNetworkDrive method.

VBScript for Network drive Mapping

The following VBScript netdrive.vbs as an example, assign the network mapping to drive Z: for a specific user; the login can be performed as a different user than the one with whom you have authenticated yourself on the client.

The corresponding variable assigned line 6 – 9 in which the placeholder is defined between quotation marks.

Assign VBScript values to variables

  1. For strDriveLetter choose a desired network drive letter.
  2. For strRemotePath add the UNC path to the network share.
  3. For strUser add the user name. If this is a member of an AD domain, the domain prefix must be given, using like domain\user.
  4. For strPassword add the users password.

Run VBScript WSH from batch

If a batch is already used, for example netlogon.bat, then from the batch file the VBScript netdrive.vbs is executed as follows:

VBScript Network Drive Mapping

If you do not want to output Visual Basic Console Screen during execution, use option /B to start the application without opening a new window.

cscript msgbox map network drive

After successfully logging in, the network drive for the Windows network share is created and then opened in Explorer.