0

The cypher-shell.bat is located at D:\GitHub\cypher-shell\cypher-shell.bat. Neither of these commands starts the shell when I put it in the Run dialog:

  • pwsh D:\GitHub\cypher-shell\cypher-shell.bat: PowerShell opens and exits immediately
  • pwsh -wd D:\GitHub\cypher-shell\cypher-shell.bat: PowerShell doesn't exit but shows this error: Set-Location: Cannot find path 'D:\GitHub\cypher-shell\cypher-shell.bat' because it does not exist.
  • pwsh -f D:\GitHub\cypher-shell\cypher-shell.bat: PowerShell opens and exits immediately

How should I do this properly?

I actually have added D:\GitHub\cypher-shell to my path. Running pwsh "& cypher-shell", pwsh ^& cypher-shell, or "%ProgramFiles%\PowerShell\7\pwsh.exe" "& 'D:\GitHub\cypher-shell\cypher-shell.bat'"in Run dialog the terminal flashes for a moment and closes. In the moment it opens I can see it messages a red error.

The reason I want to use this in PowerShell because it supports more features, like copypasting or selecting text with keyboard only. The commands are also more convenient than CMD.

FYI: about Pwsh - PowerShell | Microsoft Docs

Ooker
  • 1,969
  • 4
  • 28
  • 58
  • Why are you trying to run a batch script with powershell? Those are two completely different languages. – SomethingDark Oct 25 '21 at 04:27
  • but I need to run `cypher-shell.bat` in order to have the cypher shell – Ooker Oct 25 '21 at 04:37
  • As far as I'm aware, I'd expect your batch file to be located under the``` \bin\``` parent directory, are you sure that you're using the correct path? To locate it, try the following, From a PowerShell Prompt: `& $Env:SystemRoot\System32\where.exe /R "D:\\" "cypher-shell.bat"`, or from a Command Prompt: `%SystemRoot%\System32\where.exe /R "D:\\" "cypher-shell.bat"`. – Compo Oct 25 '21 at 09:38
  • @Compo it returns two directories `D:\Downloads\neo4j-community-4.3.5-windows\neo4j-community-4.3.5\bin\cypher-shell.bat D:\GitHub\cypher-shell\cypher-shell.bat`. I actually have added `D:\GitHub\cypher-shell` to my path – Ooker Oct 25 '21 at 09:40
  • @Compo hmm using all of them in Run dialog the terminal flashes for a moment and closes. In the moment it opens I can see it messages a red error – Ooker Oct 25 '21 at 10:14
  • Have you considered using the `-NoExit` option? – Compo Oct 25 '21 at 11:02
  • @Compo I try `pwsh -noexit "& cypher-shell"` and `pwsh -noexit ^& cypher-shell` but it still exits – Ooker Oct 25 '21 at 11:25
  • Please explain the purpose of performing this task in the 'run' dialog, I cannot think of a slower way of invoking it. Why not use a shortcut, or run a powershell script directly? – Compo Oct 25 '21 at 11:32
  • @Compo yes I want to put it in a shortcut using AutoHotKey. I though all you need is a workable run command? – Ooker Oct 25 '21 at 11:41
  • Open the command prompt, run `cd /d D:\GitHub\cypher-shell` to get to the script, and then run `cypher-shell.bat` to run the script and see what the error you're getting is. Powershell should not be involved in any part of this process. – SomethingDark Oct 25 '21 at 13:03
  • You need to fully explain what it is you are trying to achieve. Currently it appears that you now want to create a Shortcut file which runs an AutoHotkey script or executable, which runs PowerShell Core, which in turn runs Cypher-Shell from a batch file. The only way you could complicate this more is to include VB scripting too! – Compo Oct 25 '21 at 13:13
  • @SomethingDark hmm, I realize that you can select the text with keyboard and use Ctrl+C, Ctrl+V in the cmd in Windows 11. I initially want to use in PowerShell for those features. At the moment I don't need to use this via PowerShell anymore. But still, I wonder why it didn't work? – Ooker Oct 25 '21 at 14:33
  • @Ooker, please update your question by using the [edit] facility, to ensure that all of the information we need to understand your task is clear, and all of your problem codes are submitted, together with the debugging information for each. That is not a joke, and if you cannot properly clarify your task, as it now stands, your question will go unanswered, and will be closed and/or downvoted. You are not a new member on this site, so should by now know how to best receive the attention you require. – Compo Oct 25 '21 at 14:47
  • @Ooker - it didn't work because powershell can only run .ps1 files and the command prompt can only run .bat files. You can use the command prompt's Quick Edit mode to use the mouse to select text, then press ENTER once it's highlighted to copy it. – SomethingDark Oct 25 '21 at 15:08
  • @SomethingDark oh I see. I thought that PowerShell is just an upgrade version of cmd. Many of the commands in cmd can be used in PowerShell. And I can still open the bat file in PowerShell too. It's just that I can't do that on Run – Ooker Oct 26 '21 at 05:45
  • @Compo I'm sorry if I make you feel I'm not serious. I honestly had tried to provide as much information as I can think of – Ooker Oct 26 '21 at 05:53
  • Your question, as you've stated has nothing to do with the run dialog. It appears, from reading this back, that your intention is to use AHK to create a shortcut containing a command to launch cypher-shell.bat. What you need to do therefore, as has been stated many times now, is to clarify exactly what the task is, exactly what code and commands you've used to create the shortcut using AHK, and exactly what appears in the target of those resultant shortcuts, and what happens when you run/invoke each. – Compo Oct 26 '21 at 09:30

0 Answers0