Prevention is key, in my experience. I practice two critical prevention techniques, and they have worked for me to prevent, if not 100% but to an acceptable level.
First, rotate the location of planting at least every year and more if feasible. Follow up in that location with an off-season cover crop such as cereal rye. Minimizes the number of surviving eggs.
Second, practice extraordinary hygiene by removing from the garden including any compost piles all squash plants/vines at the end of growing season each year, without fail. I prefer to burn them, but for sure get them completely out of the garden space.
This works for me. I have heard of others who use trap plants such as blue hubbard squash and sacrifice them to the borers and in turn destroy both. I have never felt the need to go that step, but I would if necessary.