Jump to content

how can i create a shortcut from a batch file?


Recommended Posts


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 !

Link to comment
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?

Link to comment
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?

Link to comment
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
Link to comment
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.

Link to comment
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"""

Link to comment
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.

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...