cmder icon indicating copy to clipboard operation
cmder copied to clipboard

$ENV:CMDER_START has a double quote too much

Open Kurdym opened this issue 10 years ago • 18 comments

starting a powershell shell gives an error:

Set-Location : Illegal characters in path.
At F:\Standalone\_console\cmder\vendor\profile.ps1:90 char:5
+     Set-Location -Path "$ENV:CMDER_START"
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (C:\Users\Kurdy":String) [Set-Location], ArgumentException
    + FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.SetLocationCommand

Set-Location : Cannot find path 'C:\Users\Kurdy"' because it does not exist.
At F:\Standalone\_console\cmder\vendor\profile.ps1:90 char:5
+     Set-Location -Path "$ENV:CMDER_START"
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Kurdy":String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

And

λ echo $ENV:CMDER_START
C:\Users\Kurdy"

Starting powershell as Admin goes OK.

Kurdym avatar Aug 22 '16 11:08 Kurdym

@Jackbennett

Stanzilla avatar Aug 22 '16 18:08 Stanzilla

Is there progress? Can I provide more information?

Kurdym avatar Sep 02 '16 07:09 Kurdym

I wonder how that " got there. What is your $env:username and if you ls c:\users what's that folder named?

Finally what the registry path set to for "cmder here" either tell me from regedit or with PS;

  1. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT Add HKEY Class Root
  2. get-itemproperty "HKCR:\Directory\Shell\Cmder\Command"
  3. get-itemproperty "HKCR:\Directory\Background\Shell\Cmder\Command"

Jackbennett avatar Oct 18 '16 08:10 Jackbennett

λ echo $env:username
Kurdy
λ ls c:\users

    Directory: C:\users

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       12-10-2016     07:17                Kurdy
d-r---        13-8-2016     10:11                Public

I do use the portable version of Cmder, and always startup from my file manager "Directory Opus" with the /start argument.

λ New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT                                                                                                    

Name           Used (GB)     Free (GB) Provider      Root                                                                                                CurrentLocation 
----           ---------     --------- --------      ----                                                                                                --------------- 
HKCR                                   Registry      HKEY_CLASSES_ROOT 
λ get-itemproperty "HKCR:\Directory\Shell\Cmder\Command"
get-itemproperty : Cannot find path 'HKCR:\Directory\Shell\Cmder\Command' because it does not exist.
At line:1 char:1
+ get-itemproperty "HKCR:\Directory\Shell\Cmder\Command"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKCR:\Directory\Shell\Cmder\Command:String) [Get-ItemProperty], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
λ get-itemproperty "HKCR:\Directory\Background\Shell\Cmder\Command"
get-itemproperty : Cannot find path 'HKCR:\Directory\Background\Shell\Cmder\Command' because it does not exist.
At line:1 char:1
+ get-itemproperty "HKCR:\Directory\Background\Shell\Cmder\Command"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKCR:\Directory...l\Cmder\Command:String) [Get-ItemProperty], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand

Kurdym avatar Oct 20 '16 08:10 Kurdym

Oh ok, so powershell just does this for you when you open it all the time (in cmder of course). I thought this must be from the "CMDER Here" context menu when your use cmder.exe /register

So I'm looking at the task setting in conemu here, what's your $env:userprofile ?

Jackbennett avatar Oct 20 '16 08:10 Jackbennett

λ $env:userprofile C:\Users\Kurdy

For a moment I was afraid it was my msitake, since I added :P:"^<PowerShell^>" at the end, but I created a new task, copied the string you refered to, replaced all &quot; with " and ran that task. Same error.

Kurdym avatar Oct 20 '16 11:10 Kurdym

Have you tried leaving them as &quot; though? It might be to get around how conemu might parse that task.

Jackbennett avatar Oct 20 '16 11:10 Jackbennett

This is what I copy to a new task:

PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot; -new_console:d:&quot;%USERPROFILE%&quot;

And this error I get then:

---------------------------
ConEmu 161009a [64]
---------------------------
Can't create new console, command execution failed (code 267)

The directory name is invalid.



"F:\Standalone\_console\cmder\vendor\conemu-maximus5\ConEmu\ConEmuC64.exe"  /OMITHOOKSWARN /CINMODE=200020 /AID=19724 /GID=23668 /GHWND=0012162A /BW=169 /BH=69 /BZ=2000 "/FN=Lucida Console" /FW=3 /FH=5 /TA=10100007 /HIDE /ROOT PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command &quot;Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''&quot;



Working folder:

"&quot;C:\Users\Kurdy&quot;"



Choose your shell?
---------------------------
Yes   No   
---------------------------

Kurdym avatar Oct 20 '16 12:10 Kurdym

Will you try PowerShell -new_console:d:%USERPROFILE% -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''"; please?

Jackbennett avatar Oct 20 '16 12:10 Jackbennett

No luck: didn't work either.

Kurdym avatar Oct 20 '16 13:10 Kurdym

Not too sure about this one then, @MartiUK Can the launcher in some way be passing in $ENV:CMDER_START string with an extra quote?

Jackbennett avatar Oct 21 '16 07:10 Jackbennett

The launcher sets CMDER_START to directory given as a /START argument or the current directory.

MartiUK avatar Oct 21 '16 08:10 MartiUK

Starting by doubleclicking cmder.exe "solves" the problem. So it must be within /start

Kurdym avatar Oct 21 '16 12:10 Kurdym

If you have created a shortcut, check what you have put after /START

MartiUK avatar Oct 21 '16 13:10 MartiUK

Well, it was with Directory Opus. The command was:

@sync:F:\Standalone\_console\cmder\Cmder.exe /start "{sourcepath}"

After removing the quotes, it was OK.

Kurdym avatar Oct 22 '16 19:10 Kurdym

Are you ok now? Feel free to re-open.

Jackbennett avatar Nov 01 '16 15:11 Jackbennett

It is workable for me now, but it remains strange the cmd tab had no problems, nor did admin powershell, but the powershell did. So for me you can leave it closed. Thanks for all the help.

Kurdym avatar Nov 01 '16 18:11 Kurdym

In profile.ps1 file , Find Set-Location -Path "$ENV:CMDER_START" replace with Set-Location -Path $ENV:CMDER_START.replace("`"","")

Ultraman95 avatar Sep 24 '17 05:09 Ultraman95