Link to home
Start Free TrialLog in
Avatar of JohnnyBCJ
JohnnyBCJFlag for Canada

asked on

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.
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of JohnnyBCJ

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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
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.
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.
****Everyone would have a shortcut on their desktop to point to a bat file that would run the program****
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
So far there isn't an answer to the question. Should I request for more people to view the question?
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?
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.
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."
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!
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.
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.
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.
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.
Avatar of marsilies
marsilies

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.
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.
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
why can't you use click-once installation?
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.
same as before.. only checks for updates when launching and it goes into users appdata local folder
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!

User generated image
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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!!
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
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..
Agreed.  Accept author comment if nothing else: http:#a40915112
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
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.