why is this FOR doing this?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: why is this FOR doing this?

#16 Post by orange_batch » 30 Dec 2011 17:33

Use start cmd /k cd /d C:\

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: why is this FOR doing this?

#17 Post by taripo » 30 Dec 2011 18:23

orange_batch wrote:Use start cmd /k cd /d C:\


or click an icon.
The point is I want something efficient like start..run..cmd<ENTER> is efficient.

like start..run..cmd1<ENTER> with one process would be nice.

your one is just not efficient to get the cmd window up from start..run, it's too many keystrokes.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: why is this FOR doing this?

#18 Post by aGerman » 30 Dec 2011 20:18

As I suggested before you could create a file "cmd1.bat".

Code: Select all

@cmd /k cd C:\

Since Start->Run is searching in the path-environment you have to save it in one of the folders which are listed in %path%.

Instead of saving it into say C:\Widows I would prefer to create a folder (e.g. C:\myTools) and place the batch there. Now append this folder permanently to the %path% environment variable:
- Start->Run->SystemPropertiesAdvanced.exe
- click on Environment Variables, find "PATH" in the System Variables and double click it
- the Edit window opens, add "C:\myTools" separated by a semi colon (do NOT delete or change the other folders in this variable!)

Now you can run the batch via Start->Run->cmd1

Regards
aGerman

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: why is this FOR doing this?

#19 Post by taripo » 30 Dec 2011 20:29

@agerman

I know about the path and can run cmd1.bat efficiently. start..run..cmd1<ENTER>

The issue is it creates 2 processes. See task manager

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: why is this FOR doing this?

#20 Post by aGerman » 30 Dec 2011 20:41

taripo wrote:The issue is it creates 2 processes. See task manager

So what :roll:
Do you fear one cmd process more or less would influence the speed of your machine? Did you check the CPU-use of these processes? Perhaps it steals a bit of RAM space ...

Regards
aGerman

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: why is this FOR doing this?

#21 Post by taripo » 30 Dec 2011 21:14

it's a bit messy. but fair point..

4 cmd windows would be 8 cmd processes listed in task manager in the processes tab.

though I suppose it's not so bad..

I can close quite clearly in the applications tab(and there i see the title too)..and they don't double there. And Chrome(which I may/may not use), takes up lots of processes. and lots of notepad windows is messy too. I suppose lots of cmd windows each with 2 processes is twice as messy as it'd be with one process, but perhaps not too bad.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: why is this FOR doing this?

#22 Post by aGerman » 31 Dec 2011 07:18

Well, orange_batch already gave you the hint how to solve it if the double cmd is bugging you. To avoid that it opens a new window use START /B.

cmd1.bat

Code: Select all

@start /b cmd /k cd /d C:\

Regards
aGerman

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: why is this FOR doing this?

#23 Post by orange_batch » 02 Jan 2012 02:21

Yes, that is what I was talking about.

taripo wrote:I said it makes 2 processes, I want it to make just one.

orange_batch wrote:Use start cmd /k cd /d C:\

start will create the new cmd instance separately, which allows the first instance to reach the end (and exit) if loaded by a batch file.

Simply figure what works best for you.

Post Reply