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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a shortcut to the desktop using bat files

Status
Not open for further replies.

atojaf

Programmer
Mar 7, 2006
18
US
I need to create a shortcut on the desktop for this executble using a batch file. Please help. Thanks a bunch..

c:\CSH\csh.exe
 
The easiest way to do it would be to create the shortcut manually and then copy the shortcut file via batch file from a network share.

copy \\server\share\shortcut.lnk %userprofile%\desktop

I saw a way to actually create the .lnk file from a batch file once, but it seemed pretty convoluted to me. I may be able to find it if you absolutely have to do it this way.

 
I can't do it this way chipk, because I am trying to create an .lnk file from an .exe file not from a .lnk file
 
Tell me why you can't just do the following:-

1. Right click mouse anywhere on Desktop.

2. Select New and then Shortcut.

3. Type in location, e.g. c:\csh\csh.exe then click Next.

4. Type a name for shortcut, e.g. CSH then click finish.

ROGER - G0AOZ.
 
atojaf - I'm not sure I am following. Let me try to clarify what I meant.

You should be able to create a shortcut, which points to c:\csh\csh.exe, on a desktop manually as Roger explained above. Then copy and paste that shortcut to a shared network location. Then use a batch file to copy the .lnk file back down. It will maintain the pointers to your c:\csh\csh.exe file that you specified when you originally created it. You can use a batch file to copy that link back down to other desktops:

copy \\server\share\shortcut.lnk %userprofile%\desktop

 
I want to create a batch file so that when our users needs this icon on their desktop, I can just tell them to execute this file from their net drive- part of this batch also install create a Windows folder on their C: drive and to create a Win.ini file- chipk I had done what you suggested - create a batch to copy the .lnk file back to the desk- but for some reason it doesn't work sometimes.
 
Sorry that didn't work for you. If I find that link on creating shortcuts via batch file, I'll post it here.
 
That's chipk. I just realized what I was doing wrong on my batch file. I wasn't putting the path - C:\documents and settings - on quotes. Your last suggestions works. Now if I could just find a way to create a batch file that will enter a line of code on the Win.ini in XP, I will be done with this task. anyway, thanks again for the help.
 
Glad that worked out for you. If you don't need the entry at a specific place in the win.ini file, that should be doable.

The echo command used in conjunction with double redirects (>>) will append lines to your INI file, and any ascii file, for that matter. Emphasis because a single redirect overwrites an entire file. For instance:

echo "New Entry" >> %systemroot%\win.ini

Will create a new line that simply says "New Entry" in the win.ini file. Now, I'd make a copy of your win.ini file before doing this just to be safe.

If you need the entry like halfway down the file, though, that's a little tricky, and may require a third party tool. This is generally a lot easier on Unix.
 
I know some basic Unix commands. You're right, the line of code that I want to append to the win.ini file seem to be attaching itself to the end of entries already on the file. I wish windows has sed or grep type of utility . or omething. thanks .you helped me a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top