You can use the %basedir% variable in the commandline. You can just execute the batch file everytime, and if some condition is not met, then just exit the batch file immediately.
Hi,
I know how to set up wyUpdate to execute a file after update, but I would like to execute it only when a given condition is true.
I'm trying to execute a *.bat file and I'm searching for something similar to the %basedir% parameter, which can be set as a command line switch. Then in the *.bat file I would check the value of this parameter and decide whether I need to run it or not.
Is there a way to achieve this ?
Thanks
You can use the %basedir% variable in the commandline. You can just execute the batch file everytime, and if some condition is not met, then just exit the batch file immediately.
Thanks for the deploy.
Sorry, should have explained in more detail. I have a windows service and a winforms app part of the same application. What I want is to silently update both, but without using the AutomaticUpdater control in the winforms app.
So I implemented automatic update checking in the windows service every 20 minutes. If there is an update, the service sends a message to the winforms app.
1. If the app runs, it notifies the service that it is running and it handles update, but in silent mode. I have created a batch file and set it up to run after the update. It just calls the *.exe of the app.2. If the app doesn't run, the service will do the update.
This all works well, except that when the service does the update, it tries to start the winforms app (because the batch file is set to run after the update is completed). This results in the app being started but without a GUI, since services are not allowed to start apps because of security reasons.
So what I'm searching is a way to tell wyUpdate not to start the winforms app if the update is made from the service but start it if the update is made from the app.
Something similar to the %basedir% argument which could be provided as a command line argument to the batch file. Then in the batch file I could decide based on that argument whether to run the *.exe or not.
Hope it makes sense.
If you can be reasonably sure that your service is running under one of the standard Service User Accounts, then your batch file can check %USERNAME% to see if it ends with "Service". If it does, don't run the application.
Service User Accounts: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686005(v=vs.85).aspx