Can I run a script every time the cmd program is run?

1

I want to show unicode character on my windows console. For this I changed the cmd's font to lucida console and I'm using chcp 65001 before every session I will open a program which will display unicode characters. This only works to session where I ran chcp 65001. If an external program open the cmd instead of myself I can't control it and call chcp before. So I want run it automatically when a new cmd is run (and turn on/off as I want to). Is it possible?

Jack

Posted 2014-08-28T18:25:42.470

Reputation: 963

Question was closed 2014-08-31T03:24:24.863

what you ask for looks very similar to this, but I could be wrong!

– jjk_charles – 2014-08-28T18:34:14.650

It does what I'm looking for but on way I don't want to. As I've mentioned in the post some people did that but you windows system didn't start anymore after reboot. – Jack – 2014-08-28T18:44:28.910

oh yes, that link serves only half of your question. For the second part of your question, you could write a windows service to monitor if "cmd" is launched and call your desired program/application as soon as cmd is identified to be a running process. There might be a cleaner approach to it, but this is one of the options. – jjk_charles – 2014-08-28T19:21:35.247

Answers

1

You could use Autorun key in the registry [to run chcp 65001 for each session]

There are two variables you could use (machine and user hives)
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

Set Autorun (create it if it does not exists, type REG_SZ) to chcp 65001

wmz

Posted 2014-08-28T18:25:42.470

Reputation: 6 132