开发者

Compiling with MinGW without administrator privileges or access to the command line

I have installed DevC++ at school so I can compile C apps but every time I try to compile I get an error reading the command prompt is disabled by the sysadmin.

How can I compile anyway?

Comp开发者_运维问答iler is MinGW.


Talk to the person responsible for the school's computers and tell him/her that you want to learn programming and thus require access to a command prompt. Having a CLI available is always a good thing. And frankly: Disabling access to the command line? WTF?! That's no security at all.


I got the same problem at my school. I solved it using a little program that reads text from the console and used it as argument to system() (in C++). It worked well for me, although the current working directory etc isn't saved between the commands, but that can be solved using && to concatenate the commands and executing them at once. Just in case your teacher won't give you access to the cmd...


That sounds like pretty tight restrictions. I don't know that there are good ways around it without just re-enabling command prompt. Are you sure it's compiling that needs a command prompt? I'd think it'd be running the app that needs it, if anything.

However, before you try anything like that, it'd be a pretty good idea to try installing Code::Blocks and using that instead. C::B is much more modern than DevC++ and might not require this privilege for just compiling and running apps that don't need a console window. As a bonus, I'm pretty sure C::B is compatible with DevC++ project files and devpaks.

As an additional solution, if you're dealing with a Windows XP system, most of the time a few simple registry modifications can re-enable these things. Even if regedit is disabled, you can still edit the registry using the APIs directly; there might be tools for this across the internet.


I would try the following workaround: create a batch file (with .bat extension) with contents:

set path=%path%;c:\myfolder\mingw\bin
gcc hello.c >out.txt
start out.txt

Using command prompt is not very comfortable as you usually want to set some environment variables before launching the compiler. When you have a batch file you just double click on it. You may also add pause at the end.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜