Computing.Net > Forums > Programming > batch file programming

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file programming

Reply to Message Icon

Name: nsibon
Date: March 15, 2009 at 09:47:33 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

How do you have a batch file (xp) read another batch file and search for specific commands/text?

i am trying to create a script from preventing users from opening the command prompt using the ever-popular batch file:

COMMAND.COM


i would make the batch file the system default for opening batch files, so when a user executed the batch file, it opened the script i made, checked the file for the line "COMMAND.COM", and if it found it, prevented execution.

or if you have a better way to do this that would be great

-thanks, nathan



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: March 15, 2009 at 10:38:35 Pacific
Reply:

Command.com isn't a batch file, it a programme. command.com is what is know as a command interpreter. It is a throw back to DOS where command.com had to be running for the system to do anything. Command.com has to be running in order to execute any batch file. By the time a user runs your batch file command.com, is loaded and running

If you want to prevent user from using the Run command you can disable it in Windows XP Professional. I'm not sure you can do that in Windows XP Home though.

Stuart


0

Response Number 2
Name: nsibon
Date: March 15, 2009 at 15:47:47 Pacific
Reply:

what i meant was there is a way around the blocking of use of
the command prompt by going into notepad, typing
COMMAND.COM, saving it as a batch file, and executing it.
this brings up the command prompt wether the user is allowed
to or not.


0

Response Number 3
Name: reno
Date: March 15, 2009 at 21:44:47 Pacific
Reply:

if you want to block user from accessing command prompt, i know a way to do it from registry.

and there is a command to modify registry from command prompt, but i think it will only take effect until next restart.


0

Response Number 4
Name: nsibon
Date: March 16, 2009 at 04:50:34 Pacific
Reply:

well yes, the registry does technically block the use of the command prompt, but there is still a very simple way of getting around that (mentioned above). that's why im trying to write a script to block this work-around.


0

Response Number 5
Name: reno
Date: March 16, 2009 at 05:47:13 Pacific
Reply:

are you sure??

test.bat
command.com

double click, and then cmd window pop up:

The command prompt has been disabled by your administrator.

Press any key to continue . . .

then i goto RUN, and type command.com, it does show up the window, but no command can be executed.

Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\DOCUME~1\ADMINI~1>dir

The command prompt has been disabled by your administrator.

Press any key to continue . . .


or if you want to use a script as your default shell execute:
assuming you have set the shell to script.cmd "%1" %*

script.cmd
type "%~1"|find/i "command.com" && taskkill/im "cmd.exe" || %comspec% /k "%~1"

when i tested it out, if i rename script.cmd to script.bat, it goes into infinite loop.
i think you can get around by creating a new extension and cmd.exe as the shell.


0

Related Posts

See More



Response Number 6
Name: nsibon
Date: March 19, 2009 at 16:14:21 Pacific
Reply:

what service pack are you using? in xp im assuming.
microsoft might have fixed the problem.

and judging by the last script you posted, you are decades
ahead of me in anything to do with batch files

the problem is that it's a major hole that is exploited on the
computers at my school. im trying to find a way to close it for
my own knowledge, and maybe even to help the school,
because it's ridiculous how many people use this work-around
there.


0

Response Number 7
Name: Judago
Date: March 20, 2009 at 04:48:27 Pacific
Reply:

This is probably an obvious question but with the registry edit do you have the value of DisableCMD set to 1 or 2?

I can get command.com (but not cmd.exe) to work as mentioned above when the value is 2(on xp home sp3), but not when the value is 1. The value 2 allows batch files to execute but no command prompt, the value of 1 allows neither.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file programming

Batch File Programming www.computing.net/answers/programming/batch-file-programming/12397.html

batch file programming www.computing.net/answers/programming/batch-file-programming/17121.html

batch file www.computing.net/answers/programming/batch-file/13936.html