Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

up vote 2 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.