1

The command line looks like this:

cd C:\Program Files\Microsoft SQL Server\150\COM

snapshot.exe -Publisher [publisher] -PublisherDB [TEST] -Distributor [dist] -Publication [merge] -ReplicationType 2 -DistributorSecurityMode 1

So two commands in total

so far I have had some luck with:

subprocess.run(["C:\\Program Files\\Microsoft SQL Server\\150\\COM\\snapshot.exe","-Publisher [publisher] -PublisherDB [TEST] -Distributor [dist] -Publication [merge] -ReplicationType 2 -DistributorSecurityMode 1"])

This runs the snapshot.exe but says -Publisher [publisher] -PublisherDB [TEST] -Distributor [dist] -Publication [merge] -ReplicationType 2 -DistributorSecurityMode 1"] is not a valid parameter.

1
  • I expect each argument to snapshot.exe needs to be a separate entry in the array, viz, subprocess.run(["C:\\Program Files\\Microsoft SQL Server\\150\\COM\\snapshot.exe","-Publisher","[publisher]", "-PublisherDB", "[TEST]", "-Distributor", "[dist]", "-Publication", "[merge]", "-ReplicationType", "2", "-DistributorSecurityMode", "1"]) Commented Dec 18, 2020 at 20:06

1 Answer 1

1

Each separate string needs to be a separate string in the call to run, too.

The cd might not be necessary (most sensible tools don't care which directory they run in) but I'll add a cwd parameter too just to show how it can all be done in a single call.

subprocess.run(
        ["C:\\Program Files\\Microsoft SQL Server\\150\\COM\\snapshot.exe"
        "-Publisher", "[publisher]", "-PublisherDB", "[TEST]",
        "-Distributor", "[dist]", "-Publication", "[merge]",
        "-ReplicationType", "2", "-DistributorSecurityMode", "1"],
    # probably drop this
    cwd="C:\\Program Files\\Microsoft SQL Server\\150\\COM",
    # probably add this
    check=True)
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.