0

I received an installation project (.VDProject / Deployment project) that takes a dll and extract to certain location.
My goal is after it copies the file to the proper location, on the end of the installation/un-installation to re-start a certain Windows Service.

What is the proper way doing this ? by VBS in the "Commit" and "Uninstall" section of "Custom Actions" ?

This script doesnt work:

Set oshell = createobject("Wscript.Shell")
oshell.run"cmd.exe"
wscript.sleep 500
oshell.sendkeys "net stop ""MyService"""+("{Enter}")
wscript.sleep 5000
oshell.sendkeys "net start ""MyService"""+("{Enter}")
wscript.sleep 5000
oshell.sendkeys "exit"+("{Enter}")

set oshell = nothing

WScript.Quit
0

1 Answer 1

1

How married to VDPROJ are you? It's been killed by Microsoft in VS2012 because frankly it sucks.

The correct way to stop and start a service is to use the ServiceControl table. Sadly VDPROJ doesn't expose this table (let me count the ways it sucks).

VBScript/JScript custom actions are notoriously fragile. They are also out of process and reinventing the wheel (ServiceControl).

Commit custom actions don't run if rollback is disabled for the install or by policy.

Deferred custom actions is where you'd need to be but yes, you guessed it, VDPROJ doesn't give you that kind of control.

One technique would be create a WiX merge module to encapsulate the ServiceControl element and merge it into your VDPROJ. This is a technique I blog about. From the example you'd use the ServiceControl element but not the ServiceInstall element.

It's also possible to use ORCA to create a static tranform that contains your ServiceControl table and apply it to the VDPROJ built MSI as part of a postbuild event.

Anyways, like I was saying... just how married to VDPROJ are you? These are all hacks to get around the horribleness of that tool. It might make more sense to just move to full on WiX instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.