Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the following command to launch new ConEmu powershell consoles.

ConEmu64.exe /config "shell" /dir "c:\" /cmd powershell -new_console:n

I would like to pass an additional argument to specify a powershell script to run at startup of a new console. The following almost works but only prints the whole command and does not actually execute it:

ConEmu64.exe /config "shell" /dir "c:\" /cmd 'powershell -noexit -Command {Write-host "Hello world"}' -new_console:n

which produces:

Write-host Hello world
C:\>

while I am expecting:

Hello world
C:\>
share|improve this question
up vote 3 down vote accepted

Remove single quotas around your command. ConEmu executes intact string (command) which follows /cmd switch, with only exception - all -new_console... and -cur_console... are removed from this string before starting console.

ConEmu64.exe /config "shell" /dir "c:\" /cmd powershell -noexit -Command Write-host "Hello world" -new_console:n
share|improve this answer

Ok Figured it out, its a quoting issue, but there is still some weirdness going on:

/config "shell" /dir "c:\" /cmd 'powershell -noexit -Command "& Write-host `"Hello world""' -new_console:n

That works and produces the expected:

Hello World
C:\>

but if you look carefully the quote at the end of "Hello World" is not escaped while the first one is. If I use the seemingly correct syntax:

/config "shell" /dir "c:\" /cmd 'powershell -noexit -Command "& Write-host `"Hello world`""' -new_console:n

I get

Hello world`
C:\>
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .