A shortcut to a shortcut

I have a program that runs on a network drive. When I make a change to the program, I want to be able to upload the program to the network drive and not have to change everyones desktop shortcut to the updated program.

The logical setup would be to have all the users have a shortcut to a bat file, and the bat file points to the updated program whenever I make a change. This is my current setup but my antivirus hates it. It will cause headaches and act like my program is a virus even tho the threat is unknown. I've added everything to be exceptions list (Including the network file and the user's desktop shortcut), but my antivirus still kicks up a fuss. I'm actually on level 2 support with my antivirus company while attempting to solve the problem but the problem still exists and users are getting annoyed.

My next idea was a shortcut to a shortcut. Everyone's desktop shortcut would point to another shortcut that would point to the latest updated file. I would modify the second shortcut but Windows 7 doesn't seem to allow a shortcut to a shortcut. The shortcut always points to the program.

I'm sure situation has to happened to many programmers prior to me. The solution needs to be something along the lines of: User Desktop Shortcut -> A way to modify a shortcut -> Latest Program file

I'm open to suggestions.
JohnnyBCJAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
Lots of potential ways,

Personally I would use something like this... or are you not doing this in case a user has the file locked open?

\\server\share\production\currentver.exe

i.e. your live version is always the "right" path and rename your old ones or put them in an archived dir etc:
\\server\share\old\ver-dd-mm-yyyy.exe

Or you can create a link using mklink which might help?

Start CMD prompt, change to the dir where your files are, e.g.

cmd
cd /d X:\myprogr
mklink /h currentver.exe x:\myprog\ver123.exe

Then your program is also accessible as currentver.exe, you can make a shortcut to that for user.

Steve
1
JohnnyBCJAuthor Commented:
The problem with setting up \\server\share\production\currentver.exe is when I need to upload changes, that file will already be in use. I would never be able to make changes to the folder that is already in use.

I've never heard of mklink before. I'll have to look into this.

I thought about having a bat file that looks at a directory and selects the folder with the latest folder in it and runs the run.exe file inside that folder.

For example, lets say I have the folders like this.
\\server\share\production\06-05-15 11:55:29
\\server\share\production\06-30-15 17:56:23
\\server\share\production\07-05-15 11:45:27
\\server\share\production\10-05-15 15:52:24
\\server\share\production\10-05-15 12:23:53

Everytime I upload the program to the network drive, it'd upload the file given the current date and time stamp.

If the user's desktops bat file looked through the production folder and selected the folder with the latest date and time and ran the executable file inside that folder, this might work.

I don't know if my antivirus will kick up a virus about it tho.
0
Steve KnightIT ConsultancyCommented:
A batch file should work and work easily enough, your AV program aside, obviously open to someone dropping a random EXE in the dir though obviously your permissions for the dir would hopefully stop that!

You could also frankly write yourself a very short launcher program which checks for the latest EXE file matching a pattern in it's own dir then launches it?

To get latest EXE in dir using batch could do something like this... a VBScript could do it without a command window, but you could always set the shortcut to minimise the window while it briefly ran say.

@echo off
REM Get path of batch file as run by user
set dir=%~dp0
Set LatestFile=
REM Run down all files starting myprog.exe in this dir and take the name of the newest one
for /f "tokens=*" %%A in ('dir /b /a-d /od "%dir%\myprog*.exe"') DO Set LatestFile=%%~fA

REM If a matching file was found then launch it using START to close the cmd window
IF "%LatestFile%"=="" (
  ECHO There was no program found
) ELSE (
START "" "%LatestFile%"
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JohnnyBCJAuthor Commented:
If I run a shortcut directly to the program, my antivirus doesn't kick up a fuss but if I run a shortcut to a bat file that runs another file, all hell breaks lose with my antivirus program.

How would you change your code to make it look at a different directory and not the current one?

This file would be the one on the users desktop that would look at \\server\production or R:\production and check the exe files in each of it's folders.

R:\production\06-05-15 11:55:29\runthis.exe
R:\production\06-30-15 17:56:23\runthis.exe
R:\production\07-05-15 11:45:27\runthis.exe
R:\production\10-05-15 15:52:24\runthis.exe
R:\production\10-05-15 12:23:53\runthis.exe

If I have a shortcut on the user's desktop that points to a bat file that runs another application, my antivirus program goes crazy and sometimes the only way to solve the problem is restarting the computer.
0
Steve KnightIT ConsultancyCommented:
What AV are you running, I'd dump it!!

If you want a specific directory just change the line that says

set dir=%~dp0

to
set dir=r:\production

%0 is the name of the batch file, and %~dp0 is a way of getting the path of the batch file so it could run a file in the same dir without specifying it manually.

You could put the actual batch file on the user's desktop here say.

Another method.... if you run a login script then create a shortcut in, say, r:\production called MyApp.lnk and then in your login script copy it to the user's desktop to replace their current one:

Unless you have adjusted where the user's desktop is stored etc. then this would work:

copy /y R:\production\MyApp.lnk "%userprofile%\desktop"

Then when the user logs in they would get the new icon on their desktop.

Steve
0
JohnnyBCJAuthor Commented:
AVG has too many perks to give up. Especially when it's installed on over 100 computers.

Does this batch file look at the folders, or just 1 directory and looks at the latest myprog.exe?

I could use this method in theory but it wouldn't work in production. I can't overwrite files that are already in use so it would prevent me from uploading my latest program to the same folder as my previous upload.

Everytime I upload the program to the network drive, a folder with the date and time stamp gets created
like (06-25-2015@10-50-36.15), the program gets copied inside this folder.

What changes to I need to make so it'll look at the latest folder date and run myprog.exe inside of that folder?

I think that would solve my problem as the date and time stamp are always current.
0
JohnnyBCJAuthor Commented:
The problem with copying the file to their desktop every time they log in is because during the busy season, I might need to make 20 changes to the program in the same day and all users need to be running the latest version.

Getting them to log off and on to get the latest version would be a waste of time compared to just closing and reopening the program.
0
Steve KnightIT ConsultancyCommented:
This looks for the latest subdir of R:\production then

@echo off
REM Get path of batch file as run by user
set dir=R:\production
Set LatestDir=
REM Run down all files starting myprog.exe in this dir and take the name of the newest one
for /f "tokens=*" %%A in ('dir /b /ad /od "%dir%"') DO Set LatestDir=%%~A

REM If a matching file was found then launch it using START to close the cmd window
IF "%LatestDir%"=="" (
  ECHO There was no dir found
) ELSE (
START "" "%LatestDir%\myprog.exe"
)
0
JohnnyBCJAuthor Commented:
I fixed your code slightly and even tho it did load the program, AVG kicked up a fuss again.

I had to change your second last line of code to:
START "" "%dir%\%LatestDir%\myprog.exe"

The bonus of this should be, I only need to add the exception once and hopefully it'll fix the problem. I'll let you know how if it works out the way we hope it does tomorrow as the office is closed now.
0
Steve KnightIT ConsultancyCommented:
I'm surprised at AVG, been using it for many years as free home, our own business and for my customers.   Hopefully they can sort out whatever issue is causing that for you.

Yes, sorry copy/paste error, kids bed time here!

Steve
0
Danny ChildIT ManagerCommented:
I don't see why having **links** to a file would cause it to be unable to be changed.  Of course, if the file is in USE, it's hard to change it, but whether you launched it directly, via a batch, or a shortcut to a shortcut - to me, there's no difference.  If the file handle on it is marked Open, that's it.

Unless...
you use a program to break the locks, then you can do what you want:
Lock Hunter - http://lockhunter.com/
Process Explorer - free, from MS - should do it too - https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
Unlocker - http://download.cnet.com/Unlocker/3000-2248_4-10493998.html

The other option would be to use PSkill to kill all processes on the CLIENT pcs that are using the file, thus freeing it up for changes.  Bit brutal, and not sure if your guys would lose work, but worth trying
pskill  \\pcname program.exe
https://technet.microsoft.com/en-us/sysinternals/bb896683.aspx
 - easy to write a batch to do ALL your PCs.
0
JohnnyBCJAuthor Commented:
This is how it was originally setup.

Everyone on their desktop would point to a bat file which would run the program.
Whenever I uploaded the latest version, it would be uploaded in a folder with the current date and time.
I would then change the content of the bat file to point to the latest version of the file.

Every time I would change the content of the bat, AVG would act as if there was no exception for the folder.
AVG would not kick  up a fuss about the short cut on their desktop but it would kick up a fuss over the bat file.

I'm already on level 2 support for them and their excuse to fix the problem is put the entire folder in the exception list. This would give me nightmares if this was the end solution.
0
JohnnyBCJAuthor Commented:
****Everyone would have a shortcut on their desktop to point to a bat file that would run the program****
0
LeeTutorretiredCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
JohnnyBCJAuthor Commented:
So far there isn't an answer to the question. Should I request for more people to view the question?
0
Neil RussellTechnical Development LeadCommented:
JohnnyBCJ, the problem is that you need to make 20 changes to a PROGRAM in one day!  No program that is correctly written needs to change 20 times in a day, any day.

IF you have lots of parameters that determine how your program works then extract them from code and store them in a database or in a configuration/INI file.

Alternatively make the EXE that is pointed to by the shortcut a Stub application that NEVER changes but when launched looks for the latest version of another executable and launches that for the user, a common technique.

It would be most helpful to understand why you are making upto 20 changes to an applications code in a day. can you explain why?
0
David Johnson, CD, MVPOwnerCommented:
The problem with copying the file to their desktop every time they log in is because during the busy season, I might need to make 20 changes to the program in the same day and all users need to be running the latest version.
That implies that something intrinsically is wrong with your program
Getting them to log off and on to get the latest version would be a waste of time compared to just closing and reopening the program.

Us a run-once installer from the visual studio publish app setings.
0
JohnnyBCJAuthor Commented:
I've written about 5... make that 8 responses and deleted them because I don't want to sound rude.

I'll answer your question even tho I feel like it won't help the answer I'm looking for.

Lets throw this idea out there:
The client requires you to create 20 different reports but doesn't tell you what the next report is until you finished the one you're working on. After you're done each report, he wants to see it to see if he wants any changes done to each report after he's given it to you. After he's happy with the report, he gives you the requirements for the next report and the process continues and repeats.

Now change the 20 reports into 50 or 100 reports. It's incomprehensible to me how you can make the statement "No program that is correctly written needs to change 20 times in a day, any day."
0
Neil RussellTechnical Development LeadCommented:
You move the report definitions into a config file.  You application reads the config file before each attempt to print.  The definition of the report is stored in the config file so ALL you ever need to change is the config file.

We are here to help you NOT to make you  feel small or angry.  Often one approach has not been considered and it is not until somebody else mentions it that you suddenly think... OH YEAH!
0
JohnnyBCJAuthor Commented:
That implies that something intrinsically is wrong with your program

Or the program is always in a constant work in progress. As the client comes up with new reports, or new screens, I'm responsible to make it happen. My oldest developed program is 8 years old and there are still additions being added to it. Not nearly as often as the first year or two, but it still changes.
0
Neil RussellTechnical Development LeadCommented:
Adding new screens is a totally different matter to altering a report.  A report definition is easily stored in a config file and read in and applied at run time.

And I agree entirely, if you are changing an application once a day, let alone 20, then it intrinsically wrong.

Application design is a science and an art.  Understand methods of abstraction of logic and data better and you will realise that report definitions are just data and can therefore be stored external to the code/executable.
0
JohnnyBCJAuthor Commented:
You move the report definitions into a config file.  You application reads the config file before each attempt to print.  The definition of the report is stored in the config file so ALL you ever need to change is the config file.

You are correct, I never thought of that before but at the same time how am I able to add the report to the menu item in a vb.net program, if it's from a config file? I'd have to deal with permissions based on what the user has access to, as not all users have access to all reports.

Reports was a bad suggestion but it was the first thing that popped in my mind. Replace the word 'Reports' with the word 'Forms' and I'm back at square one.
0
Neil RussellTechnical Development LeadCommented:
Well permissions is easy, its data so it goes in a database.
Menus? Same this each report you store externally has a "Menu location" and that is used at load time to define what reports are shown where.  In effect your menu becomes dynamic based on what definitions are in your database.

Depending on what your "Forms" are, there is no reason why you can not take the same approach.  If it is simple data entry then you could abstract the definitions outside into the database as with the reports.
0
marsiliesCommented:
We have a program at work that the shortcut is to an EXE launcher for the main program. The launcher sits in the program folder, and the actual program versions sit in subfolders. There's a config file for the launcher that points to the version of the main program to execute. So it is possible, but I don't know programming so I don't know how they did it.

One option I would think of would be, for your batch file, instead of changing the batch file each time, have the batch file read a separate text file to get the path for the program. That way you only need to change the text file each time, and the batch file will stay the same and not upset your antivirus.
0
JohnnyBCJAuthor Commented:
Well permissions is easy, its data so it goes in a database.
Menus? Same this each report you store externally has a "Menu location" and that is used at load time to define what reports are shown where.  In effect your menu becomes dynamic based on what definitions are in your database.

Depending on what your "Forms" are, there is no reason why you can not take the same approach.  If it is simple data entry then you could abstract the definitions outside into the database as with the reports.


I'm not redesigning a program that has about half a million lines of code. Thank you for making me look outside the box but given my situation, your suggestion isn't a solution for me.
0
JohnnyBCJAuthor Commented:
One option I would think of would be, for your batch file, instead of changing the batch file each time, have the batch file read a separate text file to get the path for the program. That way you only need to change the text file each time, and the batch file will stay the same and not upset your antivirus.

That could be an option. I'll look into this and get back to you.
0
David Johnson, CD, MVPOwnerCommented:
I still think that a click-once application would probably be the best solution here.  

I don't envy your situation.. This program has grown into a monster.. Remember we are outsiders here and this constant update cycle is a problem.. no chance for dev/test/prod signoff's..  No clearly defined objectives and the target keeps shifting. All you can do is try to keep up with the desired changes that they want yesterday.

You are too close to the issue to be objective about the design problems which haver surfaced as the program grew by leaps and bounds and as you said it's too late now..  You deserve a significant raise and some time off.
0
JohnnyBCJAuthor Commented:
I still think that a click-once application would probably be the best solution here.  

I don't envy your situation.. This program has grown into a monster.. Remember we are outsiders here and this constant update cycle is a problem.. no chance for dev/test/prod signoff's..  No clearly defined objectives and the target keeps shifting. All you can do is try to keep up with the desired changes that they want yesterday.

You are too close to the issue to be objective about the design problems which haver surfaced as the program grew by leaps and bounds and as you said it's too late now..  You deserve a significant raise and some time off.

You nailed it. I'm taking my first week off in 3 years in 16 days and counting.
0
Steve KnightIT ConsultancyCommented:
One option I would think of would be, for your batch file, instead of changing the batch file each time, have the batch file read a separate text file to get the path for the program. That way you only need to change the text file each time, and the batch file will stay the same and not upset your antivirus.


That could be an option. I'll look into this and get back to you.

I believe I suggested and offered a solution for similar above, in that case reading the directory and running the latest version based on the time stamps.  Reading a text file would also be trivial if an option.

The main issue here I think is are you finding AVG is complaining over the batch file itself being changed, or of the fact that it is running a different exe that is not trusted?

Steve
0
JohnnyBCJAuthor Commented:
I believe I suggested and offered a solution for similar above, in that case reading the directory and running the latest version based on the time stamps.  Reading a text file would also be trivial if an option.

The main issue here I think is are you finding AVG is complaining over the batch file itself being changed, or of the fact that it is running a different exe that is not trusted?

Steve

If AVG never kicked up such a problem I would never have a reason to ask this question. The directory that the program is in is a trusted directory. I had to setup the network to be trusted otherwise all the users would get a warning about running an application in an non trusted zone.

I don't know about how to make the EXE trusted. Something I may have to look into.

If you add the bat file to the exception list once, it's good until the bat file changes. After the bat file changes, AVG kicks up another stink.
0
Steve KnightIT ConsultancyCommented:
Which is why I gave a batch file that then reads the directory to find the current (latest) version as then it should be trusted once and be the same, surely?  Is there any reason not to put the batch file in your excluded directory structure too?

I use AVG and have done for a long time but never had such issues either with my own or many customers who run it including networks with network drive based applications being run, is odd.

To read a specific file instead of latest in dir to get the filename add it maybe something like this:

@echo off
REM Get path of batch file as run by user
set BaseDir=R:\production
if not exist "%BaseDir%\Myapp.txt" (
  ECHO Config file not found
  EXIT /B
)
REM Get subdir under Basedir path from config file - has one line in with the path, or use this as full path inc. exe name if wanted etc.
for /f "tokens=*" %%A in ('type "%BaseDir%\Myapp.txt"') DO Set LatestDir=%%~A

PUSHD "%BaseDir%\%LatestDir%"
START "" "myprog.exe"

Open in new window



Steve
0
JohnnyBCJAuthor Commented:
Which is why I gave a batch file that then reads the directory to find the current (latest) version as then it should be trusted once and be the same, surely?  Is there any reason not to put the batch file in your excluded directory structure too?

I use AVG and have done for a long time but never had such issues either with my own or many customers who run it including networks with network drive based applications being run, is odd.

To read a specific file instead of latest in dir to get the filename add it maybe something like this:

This seems to work. AVG kicks up a fuss at first but if I change the contents of the txt file, AVG doesn't kick up more fuss after I add it to the exception list.

The only reason why it's not an acceptable solution (which is something I don't think I mentioned before), is the ICON used for bat files (which apparently are genetic and not able to change). I'm aware there are bat to exe programs out there but I'm uneasy using them because they're also used a lot for creating viruses.

Your solution is still valid, it's just unfortunate I can't use it. I'll end this question later tonight.

Thank you for everyone's time, effort, help and contribution to one heck of a problem.
0
David Johnson, CD, MVPOwnerCommented:
why can't you use click-once installation?
0
JohnnyBCJAuthor Commented:
why can't you use click-once installation?

I never noticed your 'run once' comment before, my apologizes. I guess in theory it could work. I don't know if it would work in the real world as some users may not be as computer wise as others. The majority of users aren't administrators to the computer they're using my application on so I don't know if there would be any permission problems with installing an update. The other thing is most of my updates or changes are made specifically for 3 or 4 people out of the 100+. Would that mean everyone would have to install the updates (if permissions allowed), just so 3 or 4 would see the changes?

Right now, they simply close to program and open it back up and everything works. If they don't need the update, they're not aware they need to close down and by the time the next morning, everyone is on the same version anyways.
0
David Johnson, CD, MVPOwnerCommented:
same as before.. only checks for updates when launching and it goes into users appdata local folder
0
Steve KnightIT ConsultancyCommented:
It does seem there are lots of ways of solving this, perhaps tidying up how it is done along the way but also understand you just want something that works!

Examples of icons to batch files
A shortcut is only a file - .LNK file - which you can soon copy down to the desktop etc. like I said before.  Then you would have:

shortcut.lnk = static on users desktop pointing at \\server\share\yourlauncher.cmd or \\server\share\yourlauncher.exe if you make yourself a starter.

yourlauncher.cmd - reads file or directory to find current version to use.  You could also have others, e.g.
launcherbeta.cmd - reads file or whatever to launch current test version for user before live to all?

Another thought.  Have the latest normal version in \\server\share\yourapp.exe or whatever.  Point users at that.  If they want an updated version during the day for their purpose have a button or option in the app, perhaps a per-user setting to know if they are interested in updates that prompts them one is available and re-launches from that version.

Steve
0
sarabandeCommented:
i would like to pick up a suggestion made by marsilies to read the executable path from a text file and give answers to some con's made.

The problem with setting up \\server\share\production\currentver.exe is when I need to upload changes, that file will already be in use. I would never be able to make changes to the folder that is already in use.
that's why you need to copy the new program to a new folder always.

The only reason why it's not an acceptable solution .... is the ICON used for bat files (which apparently are genetic and not able to change)
.
if you add a new link to desktop you first get the wheel icon for .bat files. via properties of the icon you come to 'Change Symbol...' and despite of a warning you could choose any arbitrary icon provided by icon resource libraries or even from the executable the batch file was starting.

assuming that you have a share where the drive letter x is pointing to, the batch file could look like

@echo off
for /F %%e in (x:\myexe\config\x.cfg) do set MYEXE="%%e"
echo MYEXE=%MYEXE%
%MYEXE%
if not errorlevel 1 goto error 
goto end
:error
echo %MYEXE% ended with error
:end

Open in new window


and the x.cfg may contain (only) 1 line

x:\myexe\v1.0\myexe.exe

Open in new window


if you want to update you create a new folder v1.1, copy the new program there and change the config file accordingly.

of course all those easily could be done in a regular executable at the client side as well.

Sara
0
JohnnyBCJAuthor Commented:
A shortcut is only a file - .LNK file - which you can soon copy down to the desktop etc. like I said before.  Then you would have:

shortcut.lnk = static on users desktop pointing at \\server\share\yourlauncher.cmd or \\server\share\yourlauncher.exe if you make yourself a starter.

yourlauncher.cmd - reads file or directory to find current version to use.  You could also have others, e.g.
launcherbeta.cmd - reads file or whatever to launch current test version for user before live to all?

Another thought.  Have the latest normal version in \\server\share\yourapp.exe or whatever.  Point users at that.  If they want an updated version during the day for their purpose have a button or option in the app, perhaps a per-user setting to know if they are interested in updates that prompts them one is available and re-launches from that version.

Steve


I guess there's no reason not to do it this way, as that's how it's currently done. I just assumed AVG would kick up a fuss about a shortcut to a bat file but assuming is always a bad thing. I just think AVG hates bat files in general.




if you want to update you create a new folder v1.1, copy the new program there and change the config file accordingly.

of course all those easily could be done in a regular executable at the client side as well.

Sara

That's how it's currently done with the exception of reading the cfg file. I'm starting to believe this is really the right way to go about this, especially since everyone already has a shortcut to the bat file on their desktop.

Instead of changing the line of code in the bat file to point to the current version of the program, have it read the current directory from a dat or cfg file and modify the dat or cfg file to the current version every time I make an update.

The bat file never changes so it should stay on the exception list. Right now, when the bat file changes, AVG treats it like it's not in the exception list and according to AVG support, there is nothing you can do about it.

At this time this seems to be the most straight forward, easiest way to accomplish the problem on hand. Redesigning the program is a valid solution but just isn't a realistic solution to solve what should be, an easy problem to solve.

Thanks again for everyone who helped!!
0
LeeTutorretiredCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
Neil RussellTechnical Development LeadCommented:
There are numerous solutions given ALL of those are acceptable alternatives to the issue.  A Deletion is not really a good solution I dont think..
0
Steve KnightIT ConsultancyCommented:
Agreed.  Accept author comment if nothing else: http:#a40915112
0
Rob JurdEE Community AdvisorCommented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for JohnnyBCJ's comment #a40915112

for the following reason:

As recommended by the experts
0
JohnnyBCJAuthor Commented:
The solution in use now is a batch file that orders the folders by date and runs the most recently modified program. The batch file never changes so when its added to the exceptions, it works OK.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.