Batch Files

skace

Lifer
Jan 23, 2001
14,488
7
81
The easiest way is to create a shortcut before hand and then copy it with the batchfile (copy c:\temp\office.lnk c:\office).

I don't know if there is another way, this one always worked for me.
 

JJADAMS

Member
Nov 1, 2002
161
0
0
That would work but I have run into problems. I have the shortcut stored out on the server, when copying and pasting on to the local machine, it picks up the computer name that the shortcut was created on. I think there is a problem with microsoft but not sure.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
ln -s /path/filename /path/shortcut

would be the command and the script would be:

#! /bin/bash

ln -s $1 $2

and the syntax would be (if the filename was mkshortcut.sh)

mkshortcut.sh /path/to/filename /path/to/shortcut

Well at least you could, if you were running a different OS...

sorry could resist.

But so you don't think I am a troll meany. Here is a nice Dos batch file to do what you want(a bit nicer then the script I made, but not but much). I found it on the net and it suppose to be for NT. But since win2k and winXP are both can be called NT 5 and NT 5.5 home version, hopefully it will be close enough. If not then you'll just have to fix it. They also have a win98 version.

Becareful with it, though. It's all gibberish to me and I don't know what it realy does.

from here
@echo off & setlocal
::For Windows NT 4.0 users only!!!
::Creates LNK and PIF files from the command line.
::Author: Walter Zackery
if not %1[==[ if exist %1 goto start
echo You must pass the path of a file or folder to the
echo batch file as a shortcut target.
if not %1[==[ echo %1 is not an existing file or folder
(pause & endlocal & goto:eof)
:start
(set hkey=HKEY_CURRENT_USER\Software\Microsoft\Windows)
(set hkey=%hkey%\CurrentVersion\Explorer\Shell Folders)
(set inf=rundll32 setupapi,InstallHinfSection DefaultInstall)
start/w regedit /e %temp%\#57#.tmp "%hkey%"

for /f "tokens=*" %%? in (
'dir/b/a %1? 2^>nul') do (set name=%%~nx?)

for /f "tokens=2* delims==" %%? in (
'findstr/b /i """desktop"""= %temp%\#57#.tmp') do (set d=%%?)

for /f "tokens=2* delims==" %%? in (
'findstr/b /i """programs"""= %temp%\#57#.tmp') do (set p=%%?)

(set d=%d:\\=\%) & (set p=%p:\\=\%)
if not %2[==[ if exist %~fs2\nul (set d=%~fs2)
if not %2[==[ if exist %~fs2nul (set d=%~fs2)
set x=if exist %2\nul
if not %2[==[ if not %d%==%2 %x% if "%~p2"=="\" set d=%2
echo %d%¦find ":\" >nul¦¦(set d=%d%\)
(set file=""""""%1"""""")
for /f "tokens=1 delims=:" %%? in ("%file:"=%") do set drive=%%?
(set progman=setup.ini, progman.groups,,)
echo > %temp%\#k#.inf [version]
echo >>%temp%\#k#.inf signature=$chicago$
echo >>%temp%\#k#.inf [DefaultInstall]
echo >>%temp%\#k#.inf UpdateInis=Addlink
echo >>%temp%\#k#.inf [Addlink]
echo >>%temp%\#k#.inf %progman% ""group200="}new{"""
echo >>%temp%\#k#.inf setup.ini, group200,, """%name%"",%file%
start/w %inf% 132 %temp%\#k#.inf
del %temp%\#k#.inf %temp%\#57#.tmp
move %p%\"}new{\*.*" %d% >nul 2>&1
rd %p%\}new{ 2>nul
move %p%\}new{.lnk %d%\"drive %drive%.lnk" >nul 2>&1
endlocal

 

blcjr

Golden Member
Oct 28, 1999
1,010
0
0
Originally posted by: JJADAMS
Is there a way to create shortcuts with batch files? Thanks

Not sure what you are asking. Are you wanting to create a shortcut associated with a particular batch file? Or do you want a batch file that creates shortcuts for other applications?

In your second post, you mention that the shortcut is on a server, and that when you cut and paste it to the local machine, it has the name of the server in it. Well, it would. Again, it would help to know more about what you want to do. But generally, batch files are only going to run locally; for instance, you cannot create a batch file, copy or paste it to a remote machine, and then execute it on that machine remotely.

Assuming you have a batch file on a local machine that you want to associate with a shortcut, just right-click on the desktop, and use the wizard to browse to the batch file you want the shortcut to run.

But that is so easy that I suspect you are trying to do something else. Probably something remotely that is not so easy to do. The one thing you may want to do, which is not possible with batch files per se, is to have a shortcut on a local machine that executes something on a remote machine (like a server). Don't get me wrong: there are ways of doing this, but it is not something you would want an OS to allow ordinary users to do, or they could do some real damage to your server.

If that is what you want to do, let me know and I'll give you some pointers.
 

JJADAMS

Member
Nov 1, 2002
161
0
0
Thanks for your replys. Appoligies for being unclear,

Here is a short version of what I'm trying to accoplish. On the server, I have copied shortcuts from a local machine that has all the correct target paths in it to the server. All the machines that will get these short cuts will all be idenical loads, PC's, ect,... Right now, what happens when coping the shortcut from the server, it has the computers name that created the shortcut. So every time you launch the shortcut, it looks for the computer name and then executes. If that machine is offline, it errors out. I'm just trying to reduce time in entering all the paths manually.

Here is an exaample of one of the shortcuts I'm trying

The target path should show this C:\sieb2000\BIN\siebel.exe /c "c:\sieb2000\bin\bestprd3cti.cfg" /d BESTPROD

and the start in C:\sieb2000\BIN\

I hope I cleared it up a little Thanks again for your help
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
The batch file I found aught to make shortcuts for you. Just edit it too your purpose.
 

skace

Lifer
Jan 23, 2001
14,488
7
81
The target path should show this C:\sieb2000\BIN\siebel.exe /c "c:\sieb2000\bin\bestprd3cti.cfg" /d BESTPROD

and the start in C:\sieb2000\BIN\

If you make this shortcut properly on the local pc, then you shouldn't have ANY references to the local pc. Then you simply copy that shortcut (.lnk file) to the server and propogate it to any machines that need it. This has been done many, many times and never is an issue. It sounds like you are making the shortcut incorrectly and ending up with a shortcut to \\blabhbalh\c$\sieb2000\etc. If this is the case, you are making the shortcut remotely instead of locally. Make the shortcut locally first and then put a copy of that same shortcut onto the network drive.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |