Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.Bat File creating a shortcut 1

Status
Not open for further replies.

CGill

Programmer
Joined
Jan 2, 2003
Messages
51
Location
GB
Anyone able to tell me how to write a bat file which will create a shortcut on a desktop to a database. Paths would be as follows

Source: Supdox02\T:\System1.mdb

Destination: C:\WINNT\Profiles\gill01c\Desktop

I need however to supstitute the gill01c bit with the current users id.

Know its a toughy but any help would be useful.

cheeers
 
I don't know of a batch command which can create a shortcut. However, you could work round this:

1. Create a shortcut to your database, in the same folder as the database. Name this something like:

StartSystem1.lnk

(shortcuts have the file name extension .LNK, but this is very difficult to see even through Explorer!)

2. Write a .BAT or .CMD file which contains:
Code:
COPY StartSystem1.lnk C:\WINNT\Profiles\%USERNAME%\Desktop

This assumes the batch file is in the same folder as the shortcut file. If not, use:
Code:
COPY [PathToShortCut]\StartSystem1.lnk C:\WINNT\Profiles\%USERNAME%\Desktop

Notice the variable %USERNAME% - this is replaced by the environment variable USERNAME when the batch or command file runs.

3. This assumes, of course, that your workstations have a variable like this set. Open a command window and type:

Code:
SET [Enter]

... to see a full list of environment variables, e.g.
Code:
USERDOMAIN=MYSERVER
USERNAME=bob.stubbs
USERPROFILE=C:\Documents and Settings\bob.stubbs
windir=C:\WINNT

Use whatever your user name variable is called here, in your batch file, and this should work.

4. You can use this technique to post shortcuts to the user's desktop, the Startup menu etc.

5. Remember that if there are any spaces in either the source or destination path names, you must enclose them in double quotes:
Code:
COPY "My Source Folder\Filename.txt" "My Target Folder"

This is because the command interpreter looks for spaces between the word COPY, the source folder and the target folder. Any other spaces will confuse it!

I hope that this helps.



Bob Stubbs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top