adding commands to cmd

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rileyh
Posts: 147
Joined: 01 Sep 2011 03:54
Location: Perth, Western Australia

adding commands to cmd

#1 Post by Rileyh » 12 Oct 2011 01:57

Hi,
this is in response to AlleyPuppy's post about adding commands by copying them to System32.
It comes up with the text "CPU has encountered an illegal command"

Why is that and how do I fix it?

Thanks,
Rileyh

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: adding commands to cmd

#2 Post by alan_b » 12 Oct 2011 03:30

There is no sensible way to tell even an expert how to "fix it".
You have not said what you did and what you want to fix.
You failed to give a relevant link to "AlleyPuppy's post",
and on a hunch I looked at http://www.allenware.com/icsw/icswidx.htm and used Firefox Search but found no "system32".

You have been asking elementary questions about DOS.

I really doubt that it is safe for you to be putting commands into the heart of the operating system.

Thank God that it responded with "CPU has encountered an illegal command".
Had it been a legal command it would have been executed - and that could have been the death of your operating system.

You may know that "DEL *.*" can do damage if aimed at the wrong target,
but there are far worse accidents awaiting those you meddle with system32.

Windows can deliver more than enough BSOD's without user interference.

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: adding commands to cmd

#3 Post by alleypuppy » 13 Oct 2011 15:37

alan_b wrote:There is no sensible way to tell even an expert how to "fix it".
You have not said what you did and what you want to fix.
You failed to give a relevant link to "AlleyPuppy's post",
and on a hunch I looked at http://www.allenware.com/icsw/icswidx.htm and used Firefox Search but found no "system32".

You have been asking elementary questions about DOS.

I really doubt that it is safe for you to be putting commands into the heart of the operating system.

Thank God that it responded with "CPU has encountered an illegal command".
Had it been a legal command it would have been executed - and that could have been the death of your operating system.

You may know that "DEL *.*" can do damage if aimed at the wrong target,
but there are far worse accidents awaiting those you meddle with system32.

Windows can deliver more than enough BSOD's without user interference.

The "command" was merely a batch file with that only contained commands that are on Windows by default. I said in a previous post that you can make a batch file that does a certain thing and place it in the system32 folder so it can be accessed in CMD from any directory. It was a file that deletes your internet cookies. I'm not sure why it came up with a "CPU has encountered an illegal command" error. Perhaps you aren't using Windows 7 (which is the OS that I wrote the file on).

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: adding commands to cmd

#4 Post by alan_b » 13 Oct 2011 15:56

I was only aware that the O.P. had been referred to http://www.allenware.com/icsw/icswidx.htm
and because he failed to link to your post I was not aware of your post until later in the day.

I did not have a clue what crazy commands he might have put in system32,
hence my concern that he should stop whatever he was doing.

Question
How easy is it to put "commands" into Windows 7 system32.

It gives me no problem because I have UAC fully disabled and all hidden and system files visible,
but this is not safe for a novice, and I would expect UAC to block such actions

Regards
Alan

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: adding commands to cmd

#5 Post by dbenham » 13 Oct 2011 16:04

I agree with alan_b that placing your own files in system32 is probably not a great idea.

I recommend creating your own directory and then adding that directory to your PATH instead, either at the System or User environment level. I have a \Utils directory on my machine for that very purpose. In that directory I put batch files plus 3rd party utilities that I trust.

Dave Benham

Rileyh
Posts: 147
Joined: 01 Sep 2011 03:54
Location: Perth, Western Australia

Re: adding commands to cmd

#6 Post by Rileyh » 13 Oct 2011 22:32

Could you explain further about your \Utils directory dbenham?
I have a \Utils directory on my machine for that very purpose.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: adding commands to cmd

#7 Post by Ed Dyreen » 14 Oct 2011 11:40

'

Code: Select all

@echo off
set "path"
set "path=%path%;E:\MyHome\MyUtils"
set "path"

start "" "MyFileInUtils.CMD"
Don't use quotes in lengthy paths :wink:

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: adding commands to cmd

#8 Post by dbenham » 15 Oct 2011 19:01

Ed's code demonstrates how PATH works, but I don't think Rileyh wants to invoke a batch file to gain access to another :!: I think he wants his "command" to be available at all times from the command prompt without having to know the path to any batch file.

There are variables that are pre-defined before your command session starts. PATH is one of them. You can change the values of these pre-defined variables as long as you have admin privileges.

There are multiple methods to get to the window that allows modification of the values, and the details can vary depending on your version of Windows. On Vista you can get to it from the Control Panel: Select System, then select Advanced system settings, then select Environment Variables. From this point on I think the various Windows versions are the same.

There are two sections: User variables only apply to you, and System variables apply to all users of the machine. If you modify the PATH in System variables then anybody that logs in to that machine will have access to your "command". Alternatively I think you can create a PATH variable in your User section, copying the existing value from System section and then modify it as you want. I believe the PATH definition in your User section will over-ride the System value, but I'm not 100% sure.

WARNING - Make sure you do not remove any directories from the PATH, only add your directory to it. If you corrupt or drop existing directories from your PATH then you will break functionality of your system and/or installed software.

The variable editor is terrible. You will be better off if you copy the entire contents of the path edit control (Control-A followed by Control-C). Then paste it into your favorite text editor. Now you can see what you are doing. A semicolon is used to separate directories within the PATH. When finished just copy the modified value back to the variable editor.

-----------------------------------------------
Ed Dyreen wrote:Don't use quotes in lengthy paths :wink:
:?: :? Ed - I don't know if that is supposed to be a joke or serious. Either way I don't get the point.

Dave Benham

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: adding commands to cmd

#9 Post by Ed Dyreen » 16 Oct 2011 03:16

'
I was talking about the %path%, I believe it uses ; as separator not quotes.
But when I wan't to setx a variable, I just regwrite to the system:

Code: Select all

:: use to create environment variable
::(
   HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
::)

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: adding commands to cmd

#10 Post by alan_b » 16 Oct 2011 05:30

Regwrite is WAY OFF TOPIC

The O.P. is asking rudimentary questions about fundamental DOS operations in the DOSTIPS forum
and you now throw in a tiny snatch of VBScript with no clue given upon how to get a VBscript created and launched :shock:
And once a novice has accessed a rather important registry key, how safely can he blunder without GUI interaction ?
Even RegEdit is not something I would recommend for a novice.

Rileyh
Posts: 147
Joined: 01 Sep 2011 03:54
Location: Perth, Western Australia

Re: adding commands to cmd

#11 Post by Rileyh » 19 Oct 2011 00:16

Alan_b
Thank you for the post. At first (being a novice!) I didn't understand what you were talking about, but I then discovered that my equivalent of "PATH" was in lowercase letters but still the same. So it now works and I am beginning to work on what I wanted.

Thank you,
Rileyh

Post Reply