Replaceable Parameter for W2K Shortcut

  • Thread starter Thread starter Keith Nguyen
  • Start date Start date
K

Keith Nguyen

I am trying to create a shortcut on my removable drive to
point to an executable on the same device. The problem is
the letter of the drive is not fixed (for instance it's
drive M on my machine, but could be drive I on someone
else's). Is there a way (syntax) that I can in effect
create a shortcut target similar to:

%cd%\My Program\Program1.exe

Thanks,

Keith,
 
Keith Nguyen said:
I am trying to create a shortcut on my removable drive to
point to an executable on the same device. The problem is
the letter of the drive is not fixed (for instance it's
drive M on my machine, but could be drive I on someone
else's). Is there a way (syntax) that I can in effect
create a shortcut target similar to:

%cd%\My Program\Program1.exe

Thanks,

Keith,

How does the system know the target location on each
machine?
 
-----Original Message-----



How does the system know the target location on each
machine?


.
The target location is fixed except for the drive letter.
In the (DOS)command mode, a %CD% would be replaced by the
current drive letter where the shortcut resides.
Keith,
 
The target location is fixed except for the drive letter.
In the (DOS)command mode, a %CD% would be replaced by the
current drive letter where the shortcut resides.
Keith,

You will have to create a batch file in \\YourServer\Tools\xyz.bat
that contains these lines:

@echo off
if exist e:\Somedir\SomeApp.exe e:\SomeDir\DomeApp,exe & goto :eof
if exist f:\Somedir\SomeApp.exe f:\SomeDir\DomeApp.exe
if exist g:\Somedir\SomeApp.exe g:\SomeDir\DomeApp.exe

You now create an icon on the desktop that refers to the fixed
location where the batch file resides.
 
-----Original Message-----


You will have to create a batch file in \\YourServer\Tools\xyz.bat
that contains these lines:

@echo off
if exist e:\Somedir\SomeApp.exe e:\SomeDir\DomeApp,exe & goto :eof
if exist f:\Somedir\SomeApp.exe f:\SomeDir\DomeApp.exe
if exist g:\Somedir\SomeApp.exe g:\SomeDir\DomeApp.exe

You now create an icon on the desktop that refers to the fixed
location where the batch file resides.


.
Thanks for the idea, I will do that if I have no other
choices. My main goal is to have my software installed on
a removable HDD and to have any user click on the shortcut
on this drive to execute the program without having
created a shortcut on the desktop. I had tried to put my
program & supported files in the windir (for instance)
directory. The shortcut does work if I make the shortcut's
target something like %windir%\My Dir\MyProg.exe. I've
since been looking for / tried to define an environment
that would contain the current working directory but no
luck. Am I on the right track ?
Keith,
 
Thanks for the idea, I will do that if I have no other
choices. My main goal is to have my software installed on
a removable HDD and to have any user click on the shortcut
on this drive to execute the program without having
created a shortcut on the desktop. I had tried to put my
program & supported files in the windir (for instance)
directory. The shortcut does work if I make the shortcut's
target something like %windir%\My Dir\MyProg.exe. I've
since been looking for / tried to define an environment
that would contain the current working directory but no
luck. Am I on the right track ?
Keith,

%cd% is an env. variable under Win2000/XP that returns
the current working directory.

In your case I would probably do this:
1. Create a batch file that detects the drive letter of the
removable hard disk (assuming that xxx.exe is your
application executable):
@echo off
set target=
for %%a in (E F G H) do dir %%a:\xxx.exe |
find /i "xxx.exe && set target=%%a:
(unwrap line)

2. Force the target drive into the environment:
if defined target (setx target %target%) else (setx target "" -m)
setx.exe comes with the Win2000 Resource Kit.

3. Execute this batch file via the Task Scheduler at startup time
so that %target% is available to all processes.
 
-----Original Message-----



%cd% is an env. variable under Win2000/XP that returns
the current working directory.

In your case I would probably do this:
1. Create a batch file that detects the drive letter of the
removable hard disk (assuming that xxx.exe is your
application executable):
@echo off
set target=
for %%a in (E F G H) do dir %%a:\xxx.exe |
find /i "xxx.exe && set target=%%a:
(unwrap line)

2. Force the target drive into the environment:
if defined target (setx target %target%) else (setx target "" -m)
setx.exe comes with the Win2000 Resource Kit.

3. Execute this batch file via the Task Scheduler at startup time
so that %target% is available to all processes.


.
This is exactly what I need. I'll try that.
Thanks,
Keith,
 
Back
Top