1

I can create a shortcut file manually for this location (%windir%\system32\rundll32.exe advapi32.dll,ProcessIdleTasks)

I want to do the same with .bat file (Not .vbs visual basic). I tried this after googling but its not working. Please tell me correct script, and please explain each command.

@echo off
echo [InternetShortcut] >> "%AllUsersProfile%\desktop\shortcut.Ink"
echo URL="%windir%\system32\rundll32.exe" >> "%AllUsersProfile%\desktop\shortcut.ink"
sadiqeen
  • 11
  • 1
  • 4
  • 2
    may be it works better, if you make it less colourful: it's not `.ink`, it's `.lnk` (`.LNK`) – Stephan Aug 31 '17 at 18:33
  • 1
    You should be echoing `%%WinDir%%` if you want the content to read `%WinDir%`, although `%%SystemRoot%%` is preferable as `%WinDir%` is only kept for legacy reasons. Also, are you aware that modern Operating Systems do not use `%AllUsersProfile%` , they use `%Public%`. That said, any system which doesn't use only `RunDll32` without a path or extension is broken anyhow. – Compo Aug 31 '17 at 18:50
  • Well stephan, I changed .ink to .lnk, Now its creating .lnk file but in properties it doesn't have Target tab. – sadiqeen Sep 01 '17 at 07:47
  • Compo, I replaced %WinDir% with %%SystemRoot%% and %AllUsersProfile% with %Public% but still it doesn't has Target field in properties. – sadiqeen Sep 01 '17 at 07:49

1 Answers1

0

I present a small hybrid script [BAT/VBS] to create a desktop shortcut. And you can of course modify it to your purpose.

@echo off
mode con cols=87 lines=5 & color 9B
Title Shortcut Creator for your batch and applications files by Hackoo
Set MyFile=%~f0
Set ShorcutName=HackooTest
(
echo Call Shortcut("%MyFile%","%ShorcutName%"^)
echo ^'**********************************************************************************************^)
echo Sub Shortcut(ApplicationPath,Nom^)
echo    Dim objShell,DesktopPath,objShortCut,MyTab
echo    Set objShell = CreateObject("WScript.Shell"^)
echo    MyTab = Split(ApplicationPath,"\"^)
echo    If Nom = "" Then
echo    Nom = MyTab(UBound(MyTab^)^)
echo    End if
echo    DesktopPath = objShell.SpecialFolders("Desktop"^)
echo    Set objShortCut = objShell.CreateShortcut(DesktopPath ^& "\" ^& Nom ^& ".lnk"^)
echo    objShortCut.TargetPath = Dblquote(ApplicationPath^)
echo    ObjShortCut.IconLocation = "Winver.exe,0"
echo    objShortCut.Save
echo End Sub
echo ^'**********************************************************************************************
echo ^'Fonction pour ajouter les doubles quotes dans une variable
echo Function DblQuote(Str^)
echo    DblQuote = Chr(34^) ^& Str ^& Chr(34^)
echo End Function
echo ^'**********************************************************************************************
) > Shortcutme.vbs
Start /Wait Shortcutme.vbs
Del Shortcutme.vbs
::***************************************Main Batch*******************************************
cls
echo Done and your main batch goes here !
echo i am a test 
Pause > Nul
::********************************************************************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • Hackoo, your script makes a .bat file, but i want to make .lnk file for this target (%windir%\system32\rundll32.exe) on desktop (No visual basic). Just simple is that. Please share a simple script with least commands posssible (target, destination, shorcut name). – sadiqeen Sep 01 '17 at 08:02