Eu uso esse arquivo em lotes. Como você pode ver, eu não sou o autor original (alguém esperto chamado Walter Zackery), eu apenas ajustei em alguns lugares (onde diz alterado por gw)
Ele não responde à sua pergunta de título, pois não define o diretório Iniciar entrada. Ele deve fazer o que você descreve nos detalhes da pergunta.
Exemplo de chamada:
link c:\Test\test3.exe "my shortcut" c:\test\x.txt some_other_parameter another_parameter
Isso usaria test3.exe para abrir x.txt no diretório de teste, com alguns outros parâmetros (os outros parâmetros não podem ser citados).
::Subject: Re: Shortcut in start menu
::Date: Mon, 27 Dec 1999 06:34:17 -0500
::From: "Walter Zackery" <[email protected]>
::Organization: Prodigy Internet http://www.prodigy.com
::Newsgroups: alt.msdos.batch
::References: 1 , 2 , 3
::
::I posted this in an NT group 2 weeks ago, but here it is again.
::Parameter number one must be the complete path of the file or folder
::that you're trying to create a shortcut to.
::
::Parameter number two must be the complete path of the folder that you
::wish to locate the shortcut in.
::
::Parameter number three is the trickiest. It must be the complete path
::to the Programs folder. The Programs folder is the folder that
::contains your Start Menu shortcuts. It's normal location is
::c:\windows\start menu\programs, or possibly
::c:\windows\profiles\xxx\start menu\programs, where xxx is your user
::name if you're using profiles. It's possible to obtain the location of
::the Programs folder using a batch file, but doing so would more than
::double the size of the batch file, so I refrained.
::
::Parameter number four must be the name that you wish to give to the
::shortcut. Don't attach the LNK extension to this name, because Windows
::will do it for you when it creates the shortcut.
::
::Here's an example command line for the batch file.
::
::link.bat c:\windows\notepad.exe c:\windows\desktop "A Notepad Shortcut" fred.txt
:: gw 22/5/9 made certain changes:
:: uses reg not regedit, since regedit export format changed
:: can pass parameter 3 for shortcut name
:: can pass parameter 4 ,5, .. 9 for command line parameters after name, these
:: will NEVER be quoted in the shortcut so make sure to use short paths
::@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
:: gw changed so can pass name as parameter 2
if %3_==_ for /f "tokens=*" %%? in (
'dir/b/a %1? 2^>nul') do (set name=%%~nx?)
if %name%_==_ set name=%3
(set hkey=HKEY_CURRENT_USER\Software\Microsoft\Windows)
(set hkey=%hkey%\CurrentVersion\Explorer\Shell Folders)
(set inf=rundll32 setupapi,InstallHinfSection DefaultInstall)
:: gw - replaced with reg call to get inot NT4 format which findstr understands
::start/w regedit /e %temp%\#57#.tmp "%hkey%"
reg export "%hkey%" %temp%\#57#.tmp /nt4
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"""""")
:set_params
if %4_==_ goto create_file
:: can't even get quotes in with this indirect method
:: if %4==/q (
:: set params=%params% "
:: set first_in_quotes=true
:: ) else if %4==\q (
:: set params=%params%"
:: ) else if first_in_quotes==true (
:: set params=%params%%4
:: set first_in_quotes=
:: ) else set params=%params% %4
set params=%params% %4
shift
goto set_params
:create_file
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% %params%
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