• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
Sign in to follow this  
Followers 0
someuser77

how can i create a shortcut from a batch file?

29 posts in this topic

hello

i am writing a small batch file and i need it to create a shortcut on Windows 2000 to a specific file.

i know it can be done in vbs, the question is how do i do it in a batch file?

0

Share this post


Link to post
Share on other sites

I dont know how can you creat a link with a batch file ,

but when I need once that

I created the link manually , I save it (is a file)

and then I copy the link in the right

location on another computer .

if the destination file is also in the right place

(where point the link) , is ok !

0

Share this post


Link to post
Share on other sites

well, in that case i will have to carry around 2 files: the .bat and the .lnk. no fun.

the point is to make one file, that will generate what it needs.

0

Share this post


Link to post
Share on other sites
hello

i am writing a small batch file and i need it to create a shortcut on Windows 2000 to a specific file.

i know it can be done in vbs, the question is how do i do it in a batch file?

you could use this:

Shortcut creator

0

Share this post


Link to post
Share on other sites

thank you for your reply, but again:

i will need to carry around 2 files: the .bat and the .exe. no fun.

the point is to make one file, that will generate what it needs.

do you think it can be done?

i found something over here but the code is too messy for me to read. :blushing:

do you think it can be rewritten to somehting?

0

Share this post


Link to post
Share on other sites
thank you for your reply, but again:

i will need to carry around 2 files: the .bat and the .exe. no fun.

the point is to make one file, that will generate what it needs.

do you think it can be done?

i found something over here but the code is too messy for me to read.  :blushing:

do you think it can be rewritten to somehting?

where exactly is the SHORCUT code over there?

0

Share this post


Link to post
Share on other sites

I dont know if this will help here is a script that makes shortcuts .

It Works Like This

1\ You input a name

2\ You Type In a number for a icon from shell32.dll

3\ A Dialog opens up amd you use that to select the app you want

a short cut to.

4\ It leaves the shortcut on desktop.

Edit To Your Needs

  Dim shell, X1, X2, X3, Mx2, Mx2a, Z2

     Set Shell = WScript.CreateObject("WScript.Shell")

     Set ObjFSO = CreateObject("UserAccounts.CommonDialog")

    

  function recall

  X2=ObjFSO.FileName

  Mx2 = "You Selected: " & X2

  shell.popup Mx2 , 3, "Gsm ShortCut Maker", 0 + 64

  end function

  function NotThere

  X3="No File Was Selected" & Vbcrlf & "Preparing To Quit"

  shell.popup  X3, 3, "Exiting Script",0 + 64

  end function

  Function GsmGetFile

  ObjFSO.Filter = "All Files|*.*"

  InitFSO = ObjFSO.ShowOpen

  If InitFSO = False Then

   NotThere

   Wscript.Quit

Else

   X2=ObjFSO.FileName

   recall

   Set Shell = nothing

   Set ObjFSO = nothing

End If

End Function

  Set sh = CreateObject("WScript.Shell")

  Set fso = CreateObject("Scripting.FileSystemObject")

  Set oWS = WScript.CreateObject("WScript.Shell")

  struser = InputBox("Type In The Name Of The ShortCut","GsmMakeShortCut","GsmSC")

  strIcon = InputBox("Type In The Icon You Want From Shell32.dll" &_

  vbCrLf & "Recommended Icons Number Are" & vbCrLf & "15" & Space(5) & "19" & Space(5) & "155, ","GsmMakeShortCut","GsmSC")

  GsmGetFile

  strApp = X2  

         set WshShell = WScript.CreateObject("WScript.Shell")

         strDesktop = WshShell.SpecialFolders("Desktop")

         set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & struser & ".lnk")

         oShellLink.TargetPath = strApp

         oShellLink.WindowStyle = 1

         oShellLink.Hotkey = "Ctrl+Alt+e"

         oShellLink.IconLocation = "shell32.dll," & strIcon 'Zero is the index        

         oShellLink.Description = "Shortcut Script"

         oShellLink.WorkingDirectory = "\.."

         oShellLink.Save

         wshShell.Popup "Hello",4, "Gsm",0+48+1024

Edited by gunsmokingman
0

Share this post


Link to post
Share on other sites

Or an even better method:

RUNDLL32.EXE APPWIZ.CPL,NewLinkHere (Dest)

0

Share this post


Link to post
Share on other sites
Or an even better method:

RUNDLL32.EXE APPWIZ.CPL,NewLinkHere (Dest)

Tell Me how it better

Can you choice the icon

Can you select any thing on your local hard drive

Does it have the a hot key attach to it.

oShellLink.Hotkey = "Ctrl+Alt+e"

Plus It leave it on the desktop, and with minor

modification you could leave it on the start menu.

I tried it and could not find any short cuts or get it to work

on my desktop.

0

Share this post


Link to post
Share on other sites
where exactly is the SHORCUT code over there?

its a batch script designed to make a shortcut. or so it says.

thanks for the code gunsmokingman, but i will have to add a .vbs file to the batch, i'll do so if theres no other way.

Aegis, the line opens a wizard that requires user input. losing the point of the script.

what i did manage to do is to find this article about making shortcuts, but i cant get it to work. :no:

[Version] 
signature="$CHICAGO$"
[DefaultInstall]
UpdateInis=Addlink
[AddLink]
setup.ini, progman.groups,, "group1=""c:\"""
setup.ini, group1,,"""thisIsMyShortcut"",""explorer.exe"",,,,,""explorer.exe"""

0

Share this post


Link to post
Share on other sites

Make the short cut, zip it in an sfx file and direct the sfx file to unzip silently to wherever the destination is.

0

Share this post


Link to post
Share on other sites

again, in that case i will have 2 files: .bat and .exe

i am trying to make only one .bat file that will do the job.

i know i can make one .exe file that will hold all the files i need, but i wouldnt want users to think they have to install something when they dont.

0

Share this post


Link to post
Share on other sites

2someuser: You cant make shortcut from batch file - only thing you can do is to create "temporary" script/inf file from batch, call it and delete it after - this is the same technology as Rob used in your link.

0

Share this post


Link to post
Share on other sites

okay.

.vbs and .inf are bouth silent, right?

so we know how to make a .vbs, now how do i make a .inf that will create a shortcut?

0

Share this post


Link to post
Share on other sites

Simple...

[version]
signature=$chicago$

[DefaultInstall]
UpdateInis=AddShortcut

[AddShortcut]
setup.ini, progman.groups,, "group1=""Calculator Group"""
setup.ini, group1,,"""Calculator"",""%windir%\system32\calc.exe"",,,,%17%"

0

Share this post


Link to post
Share on other sites

http://www.abyssmedia.com/

This compay do a program called Qick Batch File Compiler. It converts your batch file to a an EXE and lets you inclued customs resources such as other files. Although not a batch file in the end you will only have onne file to carry around.

Maybe not what you are looking for but someting to think about

hail hail

0

Share this post


Link to post
Share on other sites

windows 2000 SP4.

thats why i posted in the windows 2000 forum. ;)

but it shouldnt make any difference. does it?

0

Share this post


Link to post
Share on other sites

You need to search this site, two different methods using inf files have been posted regarding this subject. One of the subjects has been discussed in the last few days. Try a search for +inf +shortcut

0

Share this post


Link to post
Share on other sites

If You want to run a vbs from batch plus clean up the files

This makes it only 1 file

Green is what you add to the script

Blue is the script varible

Echo off && Cls && Mode 55,5 && Color 5e && Title Shortcut

set VBS=%systemdrive%\MyVbsShortcut.vbs

>> %vbs% echo  Dim WshShell : set WshShell = WScript.CreateObject("WScript.Shell")

>> %vbs%echo  Dim Fso : set Fso = WScript.CreateObject("Scripting.FileSystemObject")

>> %vbs%echo  strDesktop = WshShell.SpecialFolders("Desktop")

>> %vbs%echo  set oShellLink = WshShell.CreateShortcut(strDesktop ^& "\  PLACE_NAME_HERE .lnk")

>> %vbs% echo   oShellLink.TargetPath = THE_LOCATION_OF_THE_SHORTCUT_TO_APP 'EG: NOTEPAD.EXE

>> %vbs%echo  oShellLink.WindowStyle = 1

>> %vbs%echo  oShellLink.Hotkey = "Ctrl+Alt+e"

>> %vbs%echo  oShellLink.IconLocation = "shell32.dll, ^& PLACE_NUNBER_OF_ICON_HERE " 'Zero is the index        

>> %vbs% echo   oShellLink.Description = "My shortcut to NAME_WHATEVER"

>> %vbs%echo  oShellLink.WorkingDirectory = "\.."

>> %vbs%echo   oShellLink.Save

>> %vbs%echo           wshShell.Popup "Hello",4, "Gsm",0+48+1024 'This Line Is safe to remove

>> %vbs%echo  Fso.deleteFile("NAME_OF_BATCH_HERE")

>> %vbs%echo  Fso.deleteFile(" %vbs% ")

start %vbs%

Edited by gunsmokingman
0

Share this post


Link to post
Share on other sites

thank you for your help, but i need to get access to the windir, unfortenately this is not working:

Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.Environment("Volatile").Item("windir")

it returns a blank line.

0

Share this post


Link to post
Share on other sites

hi,

I am new in this forum, so please guide my way...

I have foxit pdf reader that no need to be installed, just copy it into root directory or somewhere else...

my problem is, how do I make an automatic foxit shortcut into desktop ?

thanks...

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.