locked
PowerShell - Running a program with forward-slash options RRS feed

  • Question

  • I'm trying to get PowerShell script to run a program. Here is the command line I need to run:

    "D:\Program Files\Search and Replace\SR32" /r /q /u /c"\\acpfscd\content\content\XMLEdit\SandR\ACPJC\fixJCExportFiles.srs" /p"..\output\acpjc\*.xml*"

    In that format, with the quotes, etc. it ran in a batch file.

    It seems to be getting confused with the forward slashes. I have tried numerous permutations of quotes, etc. but it won't seem to work. I get errors like:

    You must provide a value expression on the right-hand side of the '/' operator.

    Can anyone help me out here?
    Saturday, July 21, 2007 8:56 PM

All replies

  • Try the PowerShell newsgroup (microsoft.public.windows.powershell), or just use the browser and go to http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.windows.powershell 

     

     

    Wednesday, August 1, 2007 2:58 AM
  • It's confused by the executable name in quotes.   Its interpreting this as a string literal, interprets the slash as division operator.   There are a couple of ways you could get around this:

     

    1) Put an ampersand (&) in front of the quoted executable name.

     

    2) Put the directory containing your tool into the PATH environment variable, so you won't need to quote it.   E.g:

        $envStick out tongueath = $envStick out tongueath + ";D:\Program Files\Search and Repalce"

        SR32 /r /q /u ...

    • Proposed as answer by Thomas Lee Friday, July 6, 2012 1:21 PM
    Wednesday, November 14, 2007 3:39 AM