VMware

How to Package a NON-Executable File Such as a Document or Spreadsheet | Main | Simple Steps for Using SBMERGE

February 09, 2010

How to Map a Drive within a ThinApp Packaged App

On occasion, we get asked how to do something like have a drive mapped before launching a ThinApp in the event the app needs to find something on the network instead of the local system or inside the Packaged app. Here is a simple script showing how to map a drive within ThinApp (before the app launches) and unmap the drive once the ThinApp packaged app is shut down.

NOTE: This will NOT be seen as a Virtual drive. Rather, this will map the network drive within Windows natively (like any other network mapped drive) so the drive will be visible to everything - including the ThinApp packaged app.


VBS ThinApp Drive Mapping Script

' DECLARE VARIABLES
Dim WSHNetwork, WSHShell, objFSO, objShell
Dim sDrive, sShare, sName

' SET GLOBAL VARIABLES
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

' SET LOCAL VARIABLES
sDrive = "<DRIVE>:" ' Set the Drive Letter to map
sShare = "\\<SERVER>\<SHARE>" ' Set the share to map the drive letter to
sName = "ThinApp Drive"


Function OnFirstParentStart
     ' Conduct Drive Mapping
     If Not objFSO.DriveExists(sDrive) Then
          WSHNetwork.MapNetworkDrive sDrive, sShare, 0
          objShell.NameSpace(sDrive).Self.Name = sName
     End If

     ' Set the current directory
     WSHShell.CurrentDirectory = sDrive & "<PATH>"  ' Set the Current Directory only if necessary.  Otherwise remark out.
End Function


Function OnLastProcessExit
     ' Unmap Drive
     WSHNetwork.RemoveNetworkDrive sDrive, True, True
End Function


The ThinApp Drive Mapping Script can be downloaded from here.


Implementation

To implement, do the following steps:

  1. Download the ThinApp Drive Mapping Script (in TXT format) and rename to a file (any name) with a ".VBS" extension.

  2. Save the ".VBS" file in the root folder of your ThinApp Project with whatever name you wish.
  3. VBS-in-Root.png

  4. Edit the ".VBS" file and replace the current values for sDrive, sShare, and sName variables to something which matches your network configuration.

  5. Example:
    ' SET LOCAL VARIABLES
    sDrive = "Z:" ' Set the Drive Letter to map
    sShare = "\\10.1.1.10\THINAPP$" ' Set the share to map the drive letter to
    sName = "My App's ThinApp Drive"

    In the example above, this will set the "Z:" drive to be mapped to the "\\10.1.1.10\THINAPP$" share and change it's name in Windows Explorer to "My App's ThinApp Drive".

    NOTE: Don't forget to also disable or set WSHShell.CurrentDirectory value to your proper path necessary.


  6. After saving your configs, run BUILD.BAT to incorporate these changes.

You are now done! Test your app to ensure the packaged app properly maps the drive before launching and unmaps the drive after closing.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c328153ef0120a88156da970b

Listed below are links to weblogs that reference How to Map a Drive within a ThinApp Packaged App:

Comments

Post a comment

If you have a TypeKey or TypePad account, please Sign In.

About this Blog

VMware ThinApp lets you deliver and deploy applications more efficiently, more securely, and more cost-effectively with agentless application virtualization.

Subscribe via RSS  

Or submit your email for updates:

End-User Computing Blog


Read additional blog posts for VMware ThinApp on the VMware End-User Computing Blog.

Visit Now

Search ThinApp Blog

Community


Discussions and resources for VMware ThinApp

Visit now

Twitter


Facebook

YouTube


    VMware Blogs