1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Shortcut thru batch file

Discussion in 'DOS/Other' started by Mark Bewick, Oct 20, 2000.

Thread Status:
Not open for further replies.
Advertisement
  1. Mark Bewick

    Mark Bewick Thread Starter

    Joined:
    Oct 19, 2000
    Messages:
    21
    Hi all,

    Does anyone know how to create a shortcut through a Batch file.

    To give you an idea, I am trying to create a desktop shortcut (C:\windows\desktop) to an .exe file

    Thanks in advance

    ------------------
    Mark Bewick
     
  2. RandyG

    RandyG

    Joined:
    Jun 26, 2000
    Messages:
    7,760
    Hi Mark,

    Usually you would run a Batch file in DOS. The windows icons that are on your desktop make it easier to do.

    What OS are you using?

    In DOS, Type "edit ???.bat"(without the quotes) where ??? is the name of your batch file. In the first line of your MS DOS Editor, you would type in the directory you wanted to target (c:\windows\desktop\). The next line would look like "***.exe""(without the quotes) where *** is the name of the program you want to open.

    If you do this in the C: directory, and that is what you open up to upon starting your system, then you will only need to type in the ??? of the batch file to open that program. You can even include the Batch file name to the end of your Autoexec.bat to have the system automatically start that program after boot up.

    Hope this helps. [​IMG]

    [This message has been edited by RandyG (edited 10-20-2000).]
     
  3. Mark Bewick

    Mark Bewick Thread Starter

    Joined:
    Oct 19, 2000
    Messages:
    21
    Thanks for your reply.

    I am using Windows 2000 Pro, but writing a batch file to be used on Windows 95 and NT 4.0 Wstation.

    I have written a batch file which reads the following to open an executable:

    Copy C:\rio32\toolbar.exe c:\windows\desktop\rio.exe

    However as this .exe file has Powerbuilder file dependancies, I just wanted to create a shortcut to this file as this would enable the path statements in the autoexec.bat to be correct, without modifications.

    Cheers

    ------------------
    Mark Bewick
     
  4. mole

    mole

    Joined:
    Aug 24, 1999
    Messages:
    781
    Mark,

    When working from the command prompt in a DOS session in Windows, you can create a shortcut with a copy of the old Pifedit.exe from Windows3.x. Place a copy of Pifedit in your path, then from the directory you want to create the *.pif in, type "Pifedit", enter in the appropriate information and choose SaveAs. Any *.pif can be started from a batchfile or the command prompt in Windows 9x or NT by using the string: "Start myfile.pif".

    If you can not find a copy of Pifedit, you can still create a *.pif from Explorer, and call that *.pif from any batch file.

    In Windows 9x, Start.exe is an executable in c:\windows\command and in WinNT, Start is an extension of the command processor. There are switches to maximize, minimize or suspend rpocessing until the application finishes. To get help for Start, type "start /?" at the command prompt.

    If you want to push-down a desktop shortcut to a number of Windows 9x workstations, as in from a LAN, you could store the *.pif on a LAN drive and copy to c:\windows\desktop on each workstation.

    Generally, Win9x and NT support a wide range of batch file commands. Win2k appears somewhat limited based on the short time I've tested it, but this may be a false impression.

    Hope that helps,

    mole
     
  5. Mark Bewick

    Mark Bewick Thread Starter

    Joined:
    Oct 19, 2000
    Messages:
    21
    Mole,

    Thanks for your response.

    So, if I wanted to created a shortcut on the desktop (C:\windows\desktop) to a file called toolbar.exe in the c:\rio32 folder, what would the statement read in the batch file.

    Would I first have to create a toolbar.pif in the rio32 directory then create a shortcut to this?

    Thanks again for your response.




    ------------------
    Mark Bewick
     
  6. mole

    mole

    Joined:
    Aug 24, 1999
    Messages:
    781
    Mark,

    To start a program, toolbar.exe from a desktop shortcut, you could take the standard route and right click the Desktop > New > Shortcut > (Enter in the appropriate file info, as in this case, c:\rio32\toolbar.exe). You might save this as ToolBar, in which case the link would have the address c:\windows\desktop\toolbar.lnk

    Once you create this, it can be started from a batch file if you want with the following:

    start c:\windows\desktop\toolbar.lnk

    You could also create a shortcut on the desktop to a batchfile located elsewhere on the PC (c:\bat\toolbar.bat for example), in this case the desktop link (actually a *.pif, which might be named ToolBar.pif). The batchfile in this case, would have the line:

    start c:\rio32\toolbar.exe


    The latter is very powerful on LANs where you might want to some time in the future, change the location of \rio32\toolbar.exe.

    Running Windows with batchfiles is very useful over a LAN, but it can take trial and error and a lot of tinkering to get everything to work smoothly. Be careful working with mixed fleets where you have Windows 9x, WinNT and Win2k as each is a bit different.

    mole
     
  7. Mark Bewick

    Mark Bewick Thread Starter

    Joined:
    Oct 19, 2000
    Messages:
    21
    Mole,

    Thanks again for your reply.

    What I need is for the batch file to create the shortcut for me - sorry, I don't think I was very clear in my previous messgages. This will save me visiting each client to make the shortuct, i.e. I want to be lazy and automate the whole thing! ;-)

    Thanks and best regards

    ------------------
    Mark Bewick
     
  8. mole

    mole

    Joined:
    Aug 24, 1999
    Messages:
    781
    Mark,

    If you are working with networked PCs, you can copy the *.lnk to each desktop from a central location on the LAN. That is the simplest way to do things.

    If you want to distribute a link to user's desktops by building one with a DOS batchfile run on each individual machine, here is an example of how to create a link to open Notepad.exe, which should work for your program "Toolbar.exe" if you make the appropriate substitutions:


    echo [InternetShortcut] > c\:windows\desktop\Notepad.url

    echo URL=c:\windows\notepad.exe >> c\:windows\desktop\Notepad.url

    echo IconIndex=1 >> c\:windows\desktop\Notepad.url

    echo IconFile=c:\windows\notepad.exe >> c\:windows\desktop\Notepad.url


    Be very careful with line wrapping here. I put carriage returns between lines so you might better see what text goes on the same line. This method creates a *.url that is plain text and points not to the internet, but to a file on your local PC. In this example Notepad.exe. All we do is "echo" the string and redirect with the > and >> to a file, in this case, I named the file Notepad.url which will show up on the Windows 9x desktop as "Notepad". The > starts the file new, >> appends to the file already there.

    Also note that the "Desktop" will be located in a different path on WinNT and Win2k. If you have other than standard installs of Win9x (installed to the c:\windows directory) your "Desktop" may be in yet another location.

    If you have more questions or need more help, let me know.

    mole
     
  9. Mark Bewick

    Mark Bewick Thread Starter

    Joined:
    Oct 19, 2000
    Messages:
    21
    Thanks you very very much. This has worked a treat.



    ------------------
    Mark Bewick
     
  10. mole

    mole

    Joined:
    Aug 24, 1999
    Messages:
    781
    Mark,

    Glad that's what you needed. Many things Windows does through the graphical user interface (GUI) can be done with batch files. Sometimes you have to cheat and do it with the GUI first, then go and replicate it with a batchfile once you see how it goes.

    mole
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads
  1. bbright20
    Replies:
    21
    Views:
    1,881
  2. thrive
    Replies:
    7
    Views:
    1,322
  3. smiely
    Replies:
    1
    Views:
    650
  4. screamoon
    Replies:
    2
    Views:
    517
  5. jpfuse
    Replies:
    0
    Views:
    650
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/30143