|
Answer» Hey guys,
i need some help with this issue. I already searched around, but couldn't find the proper SOLUTION to my problem: I want my batchfile to create a shortcut to another batchfile with the same path on the desktop. The point is i don't want static paths as i would like to redistribute this "creator". I would like to focus on possibilities that are IMPLEMENTED in WinXP. shortcut.exe doesn't exist on my system and this VBS stuff seems to be a good alternative except that i don't know the substitudes for the path in which the scipt exist and i'm not sure in general how the code should look like. It would be really cool if you can solve the issue by only using a batch file.
Best regards, Serious.RayWell for the path, use this: "%userprofile%\Desktop\FILE.BAT"
and then in the VBS (a better solution in case some computers do have shortcut.exe and some don't) would require those enviroment variables added in somehow. Ok thx for this, but the .bat files are located like this:
D:\Program Files\Game\shortcutproducer.bat D:\Program Files\Game\launcher.bat
Want-to-have: %userprofile%\Desktop\launcher.lnk
Shortcutproducer is supposed to make a shortcut (launcher.lnk) on the desktop to launcher.bat which is in the same folder as shortcutproducer.bat. So the target path for the shortcut is the same as in which shortcutproducer.bat and launcher are in: D:\Program Files\Game\. This path should be auto detected and used.A batch file might work?
C:\Documents and Settings\Bill Richardson\Desktop>type launch.bat
Code: [Select]@echo off E: CD "Program Files\Game" dir /b
call shortcutproducer.bat
dir /b
call launcher.bat C:
cd %profileuser%/desktop Output:
C:\Documents and Settings\Bill Richardson\Desktop> launch.bat launcher.bat shortcutproducer.bat Hello, This is shortcutproducer.bat launcher.bat shortcutproducer.bat Hello, This is launcher.bat
C:\Documents and Settings\Bill Richardson\Desktop>Shortcut.exe is part of the NT Server Resource Kit. It's about 11MB which is a lot of overhead for a single program. I could not find a reputable site for the single program download.
An alternative is VBScript which comes with Windows and is much more elegant than any batch file could ever hope to be.
Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk") oShellLink.TargetPath = WScript.ScriptFullName oShellLink.WindowStyle = 1 oShellLink.Hotkey = "CTRL+SHIFT+F" oShellLink.IconLocation = "notepad.exe, 0" oShellLink.Description = "Shortcut Script" oShellLink.WorkingDirectory = strDesktop oShellLink.Save
Fill in the values as needed (they are the same as if you right clicked the desktop and created a shortcut manually). Currently the script will create a shortcut to Notepad on the desktop which uses the user path to the desktop and will change from machine to machine.
Good luck.
Thanks. After additionally searching for the "current directory" stuff i was ABLE to finish my vbscript:
Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") strCurrentDirectory = WshShell.CurrentDirectory set oShellLink = WshShell.CreateShortcut(strDesktop & "\Game Launcher.lnk") oShellLink.TargetPath = strCurrentDirectory & "\launcher.bat" oShellLink.WindowStyle = 1 oShellLink.IconLocation = strCurrentDirectory & "\game.ico, 0" oShellLink.Description = "Game Launcher" oShellLink.WorkingDirectory = strCurrentDirectory oShellLink.Save So the variables i was searching for can be obtained like this:
Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") strCurrentDirectory = WshShell.CurrentDirectory
|