0

I'm trying to keep my scripts and user startups in two different folders, (the ultimate aim to hide the main program scripts)

So I have put the batch files in the script folder, created shortcuts, and placed those in "RunMe"

That works except for one proviso. The "Target" and "Start In" fields both show the drive letter AS RELATING TO MY MACHINE. When I copy folders to a USB Stick, (which is "R:" on my machine) I'm fairly certain the path will not update. More to the point, when I give USB to another end user, the drive letter in shortcut will be hopelessly wrong?

A couple of weeks ago, someone provided a 'drive independent' batch script (%~d0\foldername) ... but as far as I can tell, you can't add an icon to a batch file directly, only to a shortcut. (I want to keep the icons with my 'branding' if poss)

Anyone any workarounds?

3
  • So you have two issues to overcome then, right? You need a solution for the Target and Start In shortcut fields to be dynamic and a programmatic way to change the icons to the shortcuts? Commented Apr 3, 2019 at 15:51
  • Does this solution need to use the startup folder for any particular reason? You could use task scheduler to run a task at startup as well FYI. Perhaps if you can use such a solution, then the point of masking the subfolder script shortcut and giving it an icon is moot? Just some quick thoughts though but let me know if you can confirm or clarify any of that. Commented Apr 3, 2019 at 15:53
  • Thanks for the answers. When I duplicate, the structure will be "School Programs" and "RunMe" in the 'root'. The former is hidden, so the user only has icons in RunMe to click. Found that using "explorer" inTarget, (and adding relative path (ie "../SchoolPrograms/script.pl" StartIn blank, and placing that in "RunMe" it works without a batch file. And the window that opens,drag to size, right click and set properties. So now I get windows 9 lines high, lower left when user clicks on the shortcut, and program runs Commented Apr 3, 2019 at 17:09

1 Answer 1

0

If you want to be able to keep the functionality of a shortcut but also keep the paths portable, you can just make the shortcut links themselves relative, such as using the method described here:

%windir%\explorer.exe "..\my\files"

Of course, the drawback of this method is that you can't use the same hack to give a relative path to the icon file, so it has to be an icon that's available on the user's computer.


Edit: Instead of calling the desired program directly with explorer.exe, you can call a custom Powershell launch script that launches, repositions, and otherwise manages your programs. That way, you can use a method such as the one shown here to reposition your window.

6
  • You beat me to it. I was just going to mention that relative link with Explorer ... but NOW the problem is that you can't change the size/position of the window it pops up as you can with the CMD shortcut (!!) Commented Apr 3, 2019 at 16:13
  • Found it! You click the shortcut, move it to desired positon, right click,set properties for sizeand colours and unclick "let windows decide position" Commented Apr 3, 2019 at 16:20
  • @Cristofayre That works too :) I added a more powerful alternative as well, in case you need to do anything fancier. Commented Apr 3, 2019 at 16:23
  • Powershell. Only just getting to grips with that. Had to create a program that opened photo, compared the "time taken" stamp (Exif) with another time file, then move any photos within a range to a specified folder. From not knowing a thing,took about 8hrs to write ! Commented Apr 3, 2019 at 17:12
  • @Cristofayre Oh, I'm a PS beginner myself, too - but it's a lot easier to start with an existing script and adapt it to your needs than to work from scratch. (After all, as they say, if you know one scripting language, you know them all :P ) Commented Apr 4, 2019 at 0:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .