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 ?
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.
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.
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
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.
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.
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.....
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 ?
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.
'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.
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.
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.
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 !
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.
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.
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