Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

creating shortcuts

Original Message
Name: Sebastian42
Date: April 4, 2008 at 05:04:55 Pacific
Subject: creating shortcuts
OS: WinXP
CPU/Ram: 2.4GHz, 512Mb
Model/Manufacturer: Dell
Comment:
In my private time on a public computer, I would like to use a batch file to create shortcuts to certain programs (and delete them at the end). What DOS command would I write to e.g. create a shortcut to Notepad and place it on the desktop ?

Basty


Report Offensive Message For Removal


Response Number 1
Name: klint
Date: April 4, 2008 at 05:57:29 Pacific
Subject: creating shortcuts
Reply: (edit)
Instead of creating your own shortcuts you may prefer to use a "smart" USB flash drive using, for example, U3 technology.

If not, then an easy way to do what you asked for is to create all your shortcuts on your own C: drive, then store them in a folder on your USB drive and copy them to the desktop of the public computer.


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: April 4, 2008 at 06:43:12 Pacific
Subject: creating shortcuts
Reply: (edit)
A real' shortcut is a binary file. [.LNK] So creating it wiith DOS commands will be a mess. The batch below will mcreate a BAT on the desktop called NOTE which will start notepad.

The path to the desktop will need to be tailored.

::==

@echo off
> "C:\Documents and Settings\Administrator\Desktop\note.bat" echo start notepad test.txt


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 3
Name: klint
Date: April 4, 2008 at 07:25:14 Pacific
Subject: creating shortcuts
Reply: (edit)
Hi M2,

"The path to the desktop will need to be tailored."

Or use environment variables:

@echo off> "%USERPROFILE%\Desktop\note.bat" echo start notepad test.txt

But I was thinking of something like

@echo off
copy presavedshortcuts\*.lnk "%USERPROFILE%\Desktop"

Because then you won't get the console window appearing when you just want to start Notepad, which it would if you started it with a batch file.


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: April 4, 2008 at 07:31:12 Pacific
Subject: creating shortcuts
Reply: (edit)
good idea


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 5
Name: TanelTM
Date: April 4, 2008 at 12:46:08 Pacific
Subject: creating shortcuts
Reply: (edit)
you can create icons easily with vbs scripts.. so you can do it all with vbs scripts or you can do it like this.

notepadShortcut.bat
-------------------
echo off
set linkName=MyTestProgram
set linkPath=%userprofile%\desktop
set program=C:\WINDOWS\notepad.exe
set workDir=C:\WINDOWS\
set iconfile=C:\WINDOWS\notepad.exe
set icon=0
set windowStyle=2

echo Set oWS = WScript.CreateObject("WScript.Shell") > temp.vbs
echo sLinkFile = "%linkPath%\%linkName%.LNK" >> temp.vbs
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> temp.vbs
echo oLink.TargetPath = "%program%" >> temp.vbs
echo oLink.IconLocation = "%iconFile%, %icon%" >> temp.vbs
echo oLink.WindowStyle = "%windowStyle%" >> temp.vbs
echo oLink.WorkingDirectory = "%workdir%" >> temp.vbs
echo oLink.Save >> temp.vbs

WScript.exe temp.vbs
del temp.vbs


Report Offensive Follow Up For Removal


Response Number 6
Name: youss
Date: April 4, 2008 at 23:03:42 Pacific
Subject: creating shortcuts
Reply: (edit)
It works !

Thank's every one


Report Offensive Follow Up For Removal

Response Number 7
Name: Sebastian42
Date: April 5, 2008 at 05:59:28 Pacific
Subject: creating shortcuts
Reply: (edit)
Mechanix2Go
I have already written batch files with
'lnk', and they may theoretically be a mess, but work well in practice. The point of my question was how to CREATE a shortcut by means of a batchfile, as I have already successfully copied pre-existing shortcuts to where I want them to be.

Klint
I am all for using USB Flash Drive how you suggest, but I do NOT know what U3 is. It is NOT to Notepad that I want to create a shortcut. I just gave that as a minimal example. The path would have to be identical on the public PC and my private one... I have just experimented with a shortcut to Excel, but the properties of the shortcut copies to the flash drive contain no path !

"Because then you won't get the console window appearing when you just want to start Notepad, which it would if you started it with a batch file."
I am already (happily) using batchfiles and getting console windows - I had no idea they could be avoided. I just close them. Will have to study this !

TaneITM
You offerings look way beyond my comprehension at this point.

youss
I'm encouraged by your comment 'It works'
and will report back when I have tried the suggestions offered.

Basty


Report Offensive Follow Up For Removal

Response Number 8
Name: TanelTM
Date: April 5, 2008 at 18:02:47 Pacific
Subject: creating shortcuts
Reply: (edit)
I was in a hurry before and I had some bugs in my script(setting icon and workingDirectory didn't work) they're fixed now.

What my script does is write a VBScript file using the variables that I defined first with the SET command.
Then it executes the temp.vbs script and then deletes it after it's executed.

VBScripts work on all windows versions since win98.

All you need to do is copy paste the code and change the lines that start with SET.


Report Offensive Follow Up For Removal

Response Number 9
Name: Sebastian42
Date: April 6, 2008 at 03:59:18 Pacific
Subject: creating shortcuts
Reply: (edit)
For what it is worth, the precise purpose to which I want to put the batchfile, is to CREATE a shortcut on the public computer's desktop - a shortcut to the external drive (flash drive, memory stick, pen drive etc).
I still have no idea how to do that.

TaneITM
Thanks for your perseverence, but I am not familiar enough with VBScripts (Visual Basic ?) to make any sense of what you offer. They sound powerful and worth pursuing.....

Basty


Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: April 7, 2008 at 03:47:19 Pacific
Subject: creating shortcuts
Reply: (edit)
::

@echo off
> "\\Via-k7vm3\C\Documents and Settings\Administrator\Desktop\pen.bat" echo start explorer d:\

::


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 11
Name: Sebastian42
Date: April 7, 2008 at 06:24:29 Pacific
Subject: creating shortcuts
Reply: (edit)
Brilliant - it opens the pen drive !
Thank you !

However I found that the batch file to do that, need contain no more than just :
"start explorer f:\"
so I am intrigued why you included the term that ends in 'pen.bat'
If it is meant to place on the desktop a batchfil containing "start explorer f:\",
it fails; but I am confident I know how to do that.

Can a line be added to 'self close' the DOS window ?

Basty


Report Offensive Follow Up For Removal

Response Number 12
Name: Mechanix2Go
Date: April 7, 2008 at 09:00:10 Pacific
Subject: creating shortcuts
Reply: (edit)
"Can a line be added to 'self close' the DOS window ?"

add:

exit

::=============
the trailing \ is an old habit. won't matter much here.


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 13
Name: Sebastian42
Date: April 8, 2008 at 07:55:37 Pacific
Subject: creating shortcuts
Reply: (edit)
I have had 'exit' as the last line in various batch files, but it has not closed the DOS window.

I KNOW that TYPING 'exit' in a DOS window closes it; so I maybe I'm missing some subtlety in the coding.... ?

Basty


Report Offensive Follow Up For Removal

Response Number 14
Name: Mechanix2Go
Date: April 9, 2008 at 00:10:03 Pacific
Subject: creating shortcuts
Reply: (edit)
The behavior of EXIT is quirky.

Maybe IVO can enlighten us.


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 15
Name: Sebastian42
Date: April 9, 2008 at 01:24:11 Pacific
Subject: creating shortcuts
Reply: (edit)
IVO ?
who/what is that ?

I certainly hope I can be enlightened.

Basty


Report Offensive Follow Up For Removal

Response Number 16
Name: Mechanix2Go
Date: April 9, 2008 at 01:26:55 Pacific
Subject: creating shortcuts
Reply: (edit)
He is one of the best scrip[t guys here.


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 17
Name: Sebastian42
Date: April 10, 2008 at 02:55:56 Pacific
Subject: creating shortcuts
Reply: (edit)
How do we go about attracting IVO to our cause ?

Basty


Report Offensive Follow Up For Removal

Response Number 18
Name: TanelTM
Date: April 21, 2008 at 21:57:11 Pacific
Subject: creating shortcuts
Reply: (edit)
add the CLS command in the end of the batch script.. I think in win95/98 it gave the message "program ended" or something and didn't close the window so you could see what the window displayed but if there was nothing to display it closed.

Report Offensive Follow Up For Removal

Response Number 19
Name: Sebastian42
Date: April 24, 2008 at 06:42:29 Pacific
Subject: creating shortcuts
Reply: (edit)
'CLS' removes the DOS screen for some, but not all batch files. I can't tell what the 'failures' have in common, and how they are different from the successes.

Basty


Report Offensive Follow Up For Removal

Response Number 20
Name: klint
Date: April 24, 2008 at 08:24:57 Pacific
Subject: creating shortcuts
Reply: (edit)
I'm confused by this thread. Are we talking about Windows XP Command Processor window, or Windows 98?

I assumed it was XP as that's what it says in the details of the original post. On my XP boxes, all of my console windows always disappear as soon as the application finishes.


Report Offensive Follow Up For Removal

Response Number 21
Name: Sebastian42
Date: April 24, 2008 at 23:31:59 Pacific
Subject: creating shortcuts
Reply: (edit)
I run two systems - an XP and an Me. I can DEFINITELY say that there is mixed success in WinMe; I will carefully monitor the WinXP
response and report.

Basty


Report Offensive Follow Up For Removal

Response Number 22
Name: Sebastian42
Date: April 27, 2008 at 01:07:30 Pacific
Subject: creating shortcuts
Reply: (edit)
Klint
By sheer co-incidence I've discovered that to make 'Cls' shut the DOS window, the batch should start with 'Echo Off' - works reliably in BOTH XP & Me !

Basty


Report Offensive Follow Up For Removal

Response Number 23
Name: klint
Date: April 28, 2008 at 02:13:08 Pacific
Subject: creating shortcuts
Reply: (edit)
Thanks. I haven't used Me/98/95 for a very long time and couldn't remember what it did with windows of closed console applications. It seems reasonable to keep the windows open if an application had produced output. I don't know why this isn't done in NT/2000/XP, where you have to use a pause command instead.

Report Offensive Follow Up For Removal

Response Number 24
Name: Mechanix2Go
Date: April 28, 2008 at 04:02:48 Pacific
Subject: creating shortcuts
Reply: (edit)
Now I've heard everything.


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 25
Name: Sebastian42
Date: June 12, 2008 at 07:32:00 Pacific
Subject: creating shortcuts
Reply: (edit)
There are still batchfiles starting with 'Echo Off' and closing with 'Cls' that do NOT close - e.g when a batch asks for a document to open in an application.

Basty


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: creating shortcuts

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Slow boot time

Trasnferring Documents from old HD

My k8T Neo-v usb's aren't working!

Date Modified = Date Created Time

system files on removable harddrive


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC