1

I am trying to change the "Start In" property of a program via batch file for an install script that I am writing for windows 10. I have not been able to find any info about where or how to do this. I've been dealing with the registry to other reasons, but I can't seem to find these fields in the registry. Here is photo of what I am trying to change for more clarity.

Here is a link to the image because my reputation is too low: https://cdn.discordapp.com/attachments/362700323099246593/523723895199629315/GetAttachmentThumbnail.png

  • All shortcut data is contained in the .lnk file. You cannot modify a .lnk file through a batch file. – IInspectable Dec 16 '18 at 06:40
  • If the `.lnk` is just a text file, it could be modified from a batch file or it could be recreated from scratch using many different scripting methods.or tools. This site's purpose however, is not to do this for you it's to help you fix your own. _Please [edit the question](https://stackoverflow.com/posts/53799522/edit) to include your code and explain how it has failed to work as written and intended_. – Compo Dec 16 '18 at 09:41
  • @com: .lnk files use a binary file format. – IInspectable Dec 16 '18 at 11:19
  • @IInspectable, I specifically used `If` for a reason, were you to negate the `If` the comment would state, `it could be recreated from scratch using many different scripting methods or tools`. Regardless, until George, provides the code they're having issues with or at the very least, information about the shortcut location, and relevant shortcut's properties, this site is not the appropriate platform for their question. – Compo Dec 16 '18 at 11:57

2 Answers2

0

Download Shortcut.zip and extract it to a temporary directory. Read the file ReadMe.txt and copy the small executable Shortcut.exe written by Marty List into the directory of the batch file.

In the batch file use:

"%~dp0Shortcut.exe" /F:"C:\Path of\Shortcut.lnk" /A:E /W:"C:\Full path to new\Start in"

The small executable Shortcut.exe can be used of course also to create the *.lnk file.

Mofi
  • 46,139
  • 17
  • 80
  • 143
0

I'm partial to solutions that work with native Windows components. PowerShell has access to the Windows shell object, which is where all the shortcut behavior is defined (or, at least, accessible).

In your case, you want to set the 'WorkingDirectory' field.

$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\MyShortcut.lnk")
$Shortcut.TargetPath = "path\to\parametric.bat"
$Shortcut.WorkingDirectory = "C:\Data\proengineer"
$Shortcut.Save()

More Info

mojo
  • 4,050
  • 17
  • 24