windows - Running a batch file (with blanks) from powershell script -


i need call batch file powershell script. batch file name decided using parameters ps file user. have code not working expected. poing me mistake? seems fine getting issues actual batch file calling (one of last 4 statements)

param(   [string]$parts ) $shareddrive = "\\server\share" $cred = get-credential "domain\" $username = $cred.username $password = $cred.getnetworkcredential().password $net = new-object -com wscript.network $net.mapnetworkdrive("", $shareddrive, "true", $username, $password)  $batchfilepath = $shareddrive + "\public\upgrade\application folder" if ($parts -eq "p1") {     $selectedbatchfile = "`"" + $batchfilepath + "\p1 upgrade file.bat" + "`"" } elseif ($parts -eq "p2") {     $selectedbatchfile = "`"" + $batchfilepath + "\p1p2 upgrade file.bat" + "`"" } else {      write-host "invalid part specified. choose 1 from: p1, p2" }  $command1 =  "/k $selectedbatchfile   $username   $password"  ## tried below none worked  #& cmd "`"$command1`"" #& cmd "$command1"  #start-process "cmd.exe" -argumentlist "$command1" #start-process "cmd.exe" -argumentlist "`"$command1`"" 

is there reason want start cmd.exe /k?

start-process -filepath $selectedbatchfile -argumentlist $username,$password 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -