David Rogers
David Rogers

Reputation: 83

How do I execute a dos command with variable arguments

If I run:

<somecommand> -e "SHOW DATABASES" -u<user> -p<password>

It runs. But if I try:

<somecommand> -e "SHOW DATABASES" -u$sqlUser -p$sqlPassword

it fails because the variables are not being expanded.

What is the simplest way to accomplish this task in powershell?

Upvotes: 0

Views: 636

Answers (1)

Keith Hill
Keith Hill

Reputation: 202062

Assuming somecommand is an exe (or DOC command as you state), try it this way:

<somecommand> -e "SHOW DATABASES" "-u$sqlUser" "-p$sqlPassword"

Upvotes: 1

Related Questions