Notepad++ multiple run commands - command

How can I run cd "$(CURRENT_DIRECTORY)" followed by path/to/python.exe -i "$(FILE_NAME)" in the notepad++ run dialogue (F5) please?
I don't want to use nppexec because I want the program to run in the windows cmd window not the npp console. Also I specifically need to cd into the folder rather than relying on the default behaviour. I've tried separating the commands with semi-colons and commas, but no joy.

In the DOS/Windows command shell, you separate multiple commands on a single line using the ampersand character (&):
cmd /c cd \ptools & dir /s /b *.awk & pause
This changes to the \ptools directory, then shows every AWK file and waits for a key to be pressed.
In your case:
cmd /c cd "$(CURRENT_DIRECTORY)" & path\to\python.exe -i "$(FILE_NAME)"

Related

Keep Windows Terminal tab open after invoked WSL command

I'm trying to open a WSL (Ubuntu) tab in Windows Terminal, and then run a command in that tab using WSL. I use the following PowerShell command for that:
wt new-tab -p "WSL (Ubuntu)" wsl echo "hallo"
The problem is, after echo has run, the tab closes immediately.
Is there a way to keep it open?
When you pass a command line to wt.exe, the Windows Terminal CLI, it is run instead of a shell, irrespective of whether you also specify a specific shell profile with -p.
Thus, to achieve what you want:
Your command line must explicitly invoke the shell of interest...
...and that shell must support starting an interactive, stay-open session in combination with startup commands.
While PowerShell supports this, POSIX-compatible shells such as bash - WSL's default shell - do not.
A - suboptimal - workaround is the following:
wt -p 'WSL (Ubuntu)' wsl -e bash -c 'echo ''hello''\; exec $BASH'
Note:
Inexplicably, as of Windows Terminal v1.13.11431.0,
the ; char. inside the quoted -c argument requires escaping as \; - otherwise it is interpreted by wt.exe as its separator for opening multiple tabs / windows.
The above executes the specified echo command first, and then uses exec to replace the non-interactive, auto-closing original shell with an interactive, stay-open session via exec. The limitation of this approach is that any state changes other than environment-variable definitions made by the startup command(s) are lost when the original shell is replaced.
A better, but more elaborate solution is possible: create a temporary copy of Bash's initialization file, ~/.bashrc, append your startup commands, and pass the temporary copy's file path to bash's --rcfile option; delete the temporary copy afterwards.

Running two cmd commands in one go?

cd "C:\Program Files\GPSoftware\Directory Opus\"
followed by
dopusrt.exe /info documents\filelist1.txt,listsel,0
Attempting to run it like so;
2::
Run, %comspec% /k cd "C:\Program Files\GPSoftware\Directory Opus\" && %ComSpec% /k dopusrt.exe /info documents\filelist1.txt,listsel,0,, Hide
Return
Gives me an error. ==> The following variable name contains an illegal character: ", Hide"
It thinks, the commas in the second CMD command are AHK parameters.
I've tried quoting the second command in its entirety but the CMD window seem to only receive the first command.
Thank you.
The commas indeed are one problem, another problem is your usage of %comspec% /k.
Right now, what you're trying to, is use the Run(docs) command, where the parameters would be as follows:
Target = C:\WINDOWS\system32\cmd.exe /k cd "C:\Program Files\GPSoftware\Directory Opus\" && C:\WINDOWS\system32\cmd.exe /k dopusrt.exe /info documents\filelist1.txt
WorkingDir = listsel
Options = 0
OutputVarPID = , Hide
The comspec(docs) variable contains the path to cmd.exe and the /k switch(docs) means to run the specified command.
So, you of course don't want to specify these things twice. Just one at the start of the command. (Run a program (cmd.exe) with the specified parameters (/k, cd, "C:\Program Files\...))
And about the commas, in legacy syntax (you're writing legacy syntax here) you'll need to escape(docs) them with `,.
So in legacy syntax your finished command would look like this:
Run, %ComSpec% /k cd "C:\Program Files\GPSoftware\Directory Opus\" && dopusrt.exe /info documents\filelist1.txt`,listsel`,0, , Hide
And in modern expression syntax it'd look like this:
Run, % A_ComSpec " /k cd ""C:\Program Files\GPSoftware\Directory Opus\"" && dopusrt.exe /info documents\filelist1.txt,listsel,0", , Hide
I'd recommend ditching the legacy syntax and starting to just write expression syntax.
Here's a documentation page to get you started about the differenced between legacy syntax and expression syntax, if you're interested.
But really, this whole approach with cding to the directory where dopusrt.exe is seems really silly to me. Not seeing the point of it.
Should be fine to just run the dopusrt.exe program directly?
Run, % """C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"" /info documents\filelist1.txt,listsel,0", , Hide

AutoHotKey run command in background

I'm trying to run a command with AutoHotKey that I would normally run with cmd.exe. Here is the command:
pandoc -s "C:\input.txt" -o "D:\output.html"
This is how I do it in AutoHotKey:
#a::
run pandoc -s "C:\input.txt" -o "D:\output.html"
return
The only problem is that this opens up the a command prompt called "pandoc". Normally I'd just type in the command in cmd.exe and it would run without any hiccups or any windows opening. For this, however, that pandoc window shows up. Am I doing it correctly? Is there any easy way to suppress the window and run the command in the background?
Runs a program without opening a window. The program is "cmd.exe", the windows command shell. It is invoked with arguments "/c time /t", which outputs the current time. It redirects the output to "c:\t.txt"
program
#a::
run cmd /c time /t > c:\t.txt, c:\, hide
return
output
c:\>type c:\t.txt
14:28

How to execute multiple commands through perl script

I am trying to use perl to run two different commands - both of which need to be executed in a separate command prompt.
Here are some of the details:
when I run
system('start cmd /k "cd c:\PerlExamples && perl Perl_Ex_1.pl"');
it works as expected - it opens a new command prompt, paths to the directory I need and runs my script.
However, I want to use this system... command in a loop where each time I am running a different example script.
But when I run the following lines of code,
my $cmd = "perl Perl_Ex_1.pl";
system("start cmd /k cd c:\PerlExamples && $cmd");
it opens a new command prompt and paths to the directory I need. But it runs my example script in the original window and not in the newly opened command prompt.
Is there a way for me to do this?
Thank you.
Thanks to the wisdom of the perl monks, I found the solution to my problem.
Link to the solution:
http://www.perlmonks.org/?node_id=1173278
The solution is to either use:
my $cmd = "perl Perl_Ex_1.pl";
system(qq{start cmd /k "cd c:\\PerlExamples && $cmd"});
or use:
my $cmd = "perl Perl_Ex_1.pl";
system qq[ start /D c:\\PerlExamples cmd /k $cmd ];
Thank you.

How to create a file without a Command Prompt window

I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.
Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "wscript setup.vbs". The run of the first cmd command opens a brief command window, and I would really like to avoid this. I thought of using RunDll32 to write this data, but couldn't find any suitable API to use.
Can anyone think of a way to bypass it and create a small file with a small VBScript text without opening a Command Prompt window?
Thanks a lot,
splintor
Is the script code already in a file? If so,
You can use the TYPE command to send the script to a file:
TYPE [script_file] > setup.vbs
or COPY the script file:
COPY [script_file] setup.vbs
If the script code is in the body of your cmd, you can use the START command to run the cmd without a window (/b flag):
START /B cmd /c echo {...script code...} > setup.vbs
Rather than use cmd /c echo {...script code...} > setup.vbs as a presetup step, perhaps you could package a VBscript with your install that does your preliminary tests and creates setup.vbs, and then calls setup.vbs for you. You'd have to put this in the setup portion of the WinRAR script.
You can call another VBScript from VBScript like this:
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "wscript d:\setup.vbs, ,True
See this MSDN link for the syntax of the Run command.