PDA

View Full Version : Create shortcut from a batch script



mellingham
04-06-2003, 02:31 PM
Hi again.

I am wanting to create a shortcut to an .exe file via a batch script. The shortcut needs to be placed into the startup folder in an NT environment.

Any ideas?

Cheers,
Matt

Dylan
04-06-2003, 02:48 PM
at the top put

@echo off

to suppress the commands from comming on the screen.
then put

c:\program files\.....

write the path the the .exe file. you may need to put progra~1 (the first 6 letters then a litte ~1)

then put

exit

to exit the batch file. All this can be written in notepad but must be saved as .bat. then put it in the start up file. You may also want to add some prefix's to the program to start it minimised, etc. You'll have to look up the prefix's your self

mellingham
04-06-2003, 04:02 PM
Thanks but perhaps I need to be a little more clear...

I want the batch script to generate/create a shortcut that is placed in the startup folder to allow the program to start with windows.

I already have quite an extensive script and I want to add a command within this script to create a shortcut (.lnk file) which points to another file within the system.

I hope this is clearer?
Matt

Babe Ruth
04-06-2003, 04:49 PM
mellingham,

You could use a vbscript to do what you want...
for example (note XP example) but modify as needed for other NT-based systems...
set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("D:\Documents and Settings\All Users\Start Menu\Programs\Startup" & "\My_Notepad.lnk")
oShortCutLink.TargetPath = "D:\WINDOWS\Notepad.exe"
oShortCutLink.WindowStyle = 1
oShortCutLink.Hotkey = "CTRL+SHIFT+N"
oShortCutLink.Description = "MY_Notepad Example Shortcut"
oShortCutLink.Save
Cheers, Babe.

Kame
04-06-2003, 05:12 PM
What I understand is you want the Batch Script (probably ran during Autoexec.bat) to create a file in Startup as a shortcut. I don't believe a batch file can do that unless it's a DOS command, I'd look at COPY and see if it does any linking, only option I can suggest is create the shortcut yourself first and place it where ever you want it, then use the batch file to MOVE or COPY that file to the startup folder.

You can easily perform these options using Assembly to create a .com file (MS Debug) or Basic, I'm not sure if vbscript can be executed using a batch file while in a DOS environment.