Solved

Create a shortcut via a relative path

Posted on 2006-06-12
13
1,755 Views
Last Modified: 2008-01-16
I have a USB key chain drive that I use on various computers.  On each computer the drive letter is different.  How can I create a shortcut on the USB to point to a file releative to where I place the shortcut?

Ex. USB Driver: F:\

File path F:\ABC\123\text.txt

Would like relative path if running shortcut from F:\ABC

"\123\text.txt"  XP would permit this shotcut

Thank you.
0
Comment
Question by:thandel
  • 6
  • 6
13 Comments
 
LVL 9

Expert Comment

by:AndreDekolta
ID: 16887271
Hello thandel!

Each system would interpret it differently.  This is an XP weakness in the way it opens/reads UBS drives/ports, etc.  So, you would have to keep changing the shortcut on each system.  Sucks doesn't it!  I would like to do the same thing for my very administrative duties.  I have found some third party software.  But, you'd have to install it every system.  Not practical in my case since I have over 200 systems.

Andre...
0
 

Author Comment

by:thandel
ID: 16887402
I would think a short cut could be setup as you can do it from a DOS command.

One solution I was thinking about was simply a DOS batch file that runs and trys letters until it is sucessfull.
0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16887489
You can do a vbscript.  Smoething like this will give you the current folder:

Dim LaunchDir, FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
LaunchDir = FSO.GetFolder(".")
msgbox(LaunchDir)

So I guess you could do this:

Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
LaunchDir = FSO.GetFolder(".")

wSHShell.Run LaunchDir & "\123\text.txt"
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:thandel
ID: 16887560
Tried that but I am getting an error on the last line that it can't find the file.  I should have been more specific as the shortcut points to a folder I'm trying to open.  Sorry about that.
0
 

Author Comment

by:thandel
ID: 16887647
OK I seems to not be working because of spaces in the path... how can this be resolved?  I tried %20% but I didn't work so I must have that wrong.
0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16887655
Can you post the full path?
0
 

Author Comment

by:thandel
ID: 16887670
wSHShell.Run LaunchDir & "\HSEC\Documents and Settings\Todd\My Documents"
0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16887717
Oh, opening a directory is different.  Here you go...

Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("Shell.Application")
LaunchDir = FSO.GetFolder(".")

wSHShell.Open LaunchDir & "\HSEC\Documents and Settings\Todd\My Documents"
0
 

Author Comment

by:thandel
ID: 16887766
Well two observations.

You last code does not return an error any more but it also does nothing either.  I doesn't open a window or anything.

Second, the original code was also getting an error even when I tried to open a file.  It DID work when I tried: wSHShell.Open LaunchDir & "\HSEC\"


So I think the first code would wroke if the spaces in the full path can be resolved.
0
 
LVL 4

Accepted Solution

by:
yesplease151 earned 125 total points
ID: 16888050
Remove the \ before HSEC.  If you are running it from the root of the drive, it should not have the \.   If that doesn't work, insert a message box before the last line and let me know what it says.

msgbox(LaunchDir & "\HSEC\Documents and Settings\Todd\My Documents")
0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16888055
Spaces in the path do not matter.  It can run with the spaces.
0
 

Author Comment

by:thandel
ID: 16888106
Thankts that was it... final working code:

Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("Shell.Application")
LaunchDir = FSO.GetFolder(".")

wSHShell.Open LaunchDir & "HSEC\Documents and Settings\Todd\My Documents"


0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16888164
Great.  The reason it originally had the \ was because it was being run from F:\ABC.

Hope it works well for you.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
window s 8 to 10 err 9 120
Blocking of USB Port 18 107
will drivers for a CD/DVD recorder be needed for a Compaq laptop running Windows XP? 13 100
Move windows 10 users 8 52
Are you unable to synchronize your OST (Offline Storage Table) file with Microsoft Exchange Server? Is your OST file exceeding 2 GB size limit? In Microsoft Outlook 2002 and earlier versions, there is a 2 GB size limit for the OST file. If the file …
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question