Jump to content

question about making a shortcut from a batch file?


Recommended Posts

I have a winrar SFX file that I want to prompt the user to install, but then after I want to run a batch file that creates a shortcut to a relevant EXE on their desktop, instead of having them fish for it.

what is it that "right click, create shortcut" does exactly? when using shortcut.exe in my batch file, it wants a full path. I can't give it that, because I don't know what the user is going select for a directory. anyone know how to go about this?

im wondering if there is some dos command that can give me an environment variable that contains the full path directory the batch file was called in?

Edited by shapeless
Link to comment
Share on other sites

I got it to work!

i also thought it was impossible until i found the environment variable I was looking for: %CD%

heres my batch file to create a shortcut that will work with a user defined directory in a rar sfx:

shortcut.exe /f:"%allusersprofile%\Desktop\Program.lnk" /a:c /t:"%CD%\Program_Subdir\App.exe" /w:"%CD%\Program_Subdir"

so what happens is, the user specifies a directory for the program, lets say he uses C:\application

after it gets done unraring, the batch file runs which is located in the same directory as the exe i want the shortcut to. so then %CD% would equal whatever directory the user specifies, and a shortcut would be made. %CD% = current directory btw.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...