wxExecute without a terminal window pop up - wxwidgets

I am trying to use wxExecute this way:
wxExecute("taskkill /F /IM ASServer.exe");
and I don't intend to see the terminal window that pops up(windows). Is there a way to do that?
except this http://wiki.wxwidgets.org/WxExecute
thanks,

The way given on the wiki page you linked to is the standard way of doing it, but if you really can't stand it the following should work:
wxProcess process;
wxExecute("taskkill /F /IM ASServer.exe", wxEXEC_ASYNC, &process);

At least in 2.9 (I don't think it existed in 2.8), just pass wxEXEC_HIDE_CONSOLE flag to wxExecute().

Related

Use WMIC to get a process' window title

I was using WMIC, and I saw this:
wmic process list brief find "spotify.exe"
which should find a specific process, and return it's title, but I got an invalid list expression issue.
Anyone know what I could do instead? If preferable I would still like to use WMIC.
You should try like this way with command line :
And add this switch /I means : Case-insensitive search.
wmic process list brief | findstr /I "spotify.exe"

Renaming a Yakuake session from commandline

Yakuake provides a hotkey and a GUI way to rename commandline tabs/sessions.
I'd like to do the same via the command line, so I can script it and use it in an alias. (My goal is that if I use an alias which does an SSH to some server, then the tab is renamed according to this servers name...)
I tried the suggestions shown here Renaming a Konsole session from commandline after ssh so far no luck.
Since KDE4, one should use qdbus to control KDE apps (instead of deprecated and deleted DCOP).
For example, to change a title of the first session one may use:
qdbus org.kde.yakuake /Sessions/1 org.kde.konsole.Session.setTitle 1 "New title"
To explore available interfaces, methods and properties one may use qdbusviewer.
As a homework try to get a list of active sessions (before you going to change smth).
Like #fgysin pointed out, his command also works for me. BUT it needs the ` character and not " for the subcommand :
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId
It gives :
qdbus org.kde.yakuake /yakuake/tabs org.kde.yakuake.setTabTitle `qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId` "NEW TAB TITLE";

Batch Program Produces Strange Unexpected Output

Before I remembered how to accomplish what I was doing, I tried a couple different things, kind of just hacking at it.
What I was trying to accomplish was to set the following string as a variable and then echo it out in a batch script:
<?php require('__php__.php'); ?>
I eventually worked it out with help from SO, but before I got there, I tried this (for some reason):
set (phpStr=<? php require('__php__.php'); ?>)
Which I realize doesn't make any sense. However, how the cmd shell interpreted what I wanted to do was as follows:
set (phpStr= php require('__php__.php'); ? 0<? 1>)
In other words, when I typed the code in the second code block above, and turned on echo in the script, what showed up in the cmd shell was the command in the third code block. Then there was a syntax error, and the script exited.
Can anyone explain what happened? (Not why it didn't work. That is obvious to me, but rather, how it arrived at the interpretation it did. It's a pretty awesome restructuring of the original command. I just can't figure out how it got there.)
You need to escape redirection and other poison characters with ^ or the redirection will be active and try to create files etc. % is a special case.
You can also use something like this:
#echo off
for /f "delims=" %%a in ("<?php require('__php__.php'); ?>") do echo %%a

variable from registry (batch files)

I am making a little mod for the old game sims 1, and i thought i make a simple batch file for installing it, just to be fancy.
anyway, in the registry you can find the installpath
[HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims]
"InstallPath"="C:\\Program Files\\Maxis\\The Sims"
now, i need this to be a variable in my bat file, like
set simsdir=%installpath%
how do i do this? ive googled it but it made no sense what so ever to me so, thats why i am asking here :p
Cheers
Sounds like you need to call reg.exe
The accepted answer on 771240 looks to have the syntax you'll need. I've not tested this, but it should look something like
Set Reg.Key=HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims
Set Reg.Val=InstallPath
For /F "Tokens=2*" %%A In (
'Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' )
Do Call Set simsdir=%%B
echo %simsdir%
edit
Maybe try it with the for all on the one line, that's the only way I could get it to work. I'm a bit rusty on the 'ol batch files though
Set Reg.Key=HKEY_LOCAL_MACHINE\SOFTWARE\Maxis\The Sims
Set Reg.Val=InstallPath
For /F "Tokens=2*" %%A In ('Reg Query "%Reg.Key%" /v "%Reg.Val%" ^| Find /I "%Reg.Val%"' ) Do Call Set simsdir=%%B
echo %simsdir%

Using command output in DOS

I would like to run a command in DOS, which uses the output of another command as its part, something that single back-quote (``) allows to do on UNIX or Linux.
For example, if myCommand returns a list of files, I would like to execute in DOS some analog of the UNIX command
grep `myCommand`
How would one do that in DOS?
Thank you in advance for your help.
You can pipe two commands:
command1 | command2
But there aren't a whole lot of commands whos input/ouput plays well with each other. You'd probably be best off using a for loop. The basic syntax is:
for /f %A in ('command1') do command2 %A
Unless you try the for %%i in ... syntax, I do not see a hope in DOS. DOS is not Unix.
Another solution is to build a new batch using the for loop (with # and echo) and start the new batch at the end.
You may need to do this recursively.