In addition to the trouble with how you're formatting your command into a string, setWLSEnv.cmd
is a script for the Windows Command Prompt. PowerShell cannot execute this file; it does not know how to interpret it, much like how Notepad does not know how to interpret a docx file. Windows associates .cmd files with the command prompt, so your first line is equivalent to
& cmd.exe /c C:\bea\tpc\weblogic1033\server\bin\setWLSEnv.cmd
(Note that the semicolon is unnecessary since you don't have any other commands on the same line.)
This creates a new process using cmd.exe. This new process executes the batch file, setting the environment variables you expect, and then the process exits, discarding the environment changes.
If you need setWLSEnv.cmd
to set environment variables prior to executing your program, you should write a batch file that calls it instead of a PowerShell script. Otherwise, you will need to find or write a PowerShell equivalent to set up your environment.