Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

cmd.exe starting directory

- - - - -

  • Please log in to reply
29 replies to this topic

#1
Guillaume_fr

Guillaume_fr

    Newbie

  • Member
  • 13 posts
Hello,

When I launch cmd.exe on my XP SP2 (via Start | Run), the current directory is my Home Directory; I get this :
Microsoft Windows XP [version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.

D:\Documents and Settings\Guillaume>

How can I set up Windows to open cmd.exe in another directory (C:\ or anything else) ?

Thanx,
Guillaume.


How to remove advertisement from MSFN

#2
baywatch

baywatch

    Newbie

  • Member
  • 13 posts
hi guillaume
here do you casn find the answers.
http://www.petri.co....ws_explorer.htm

#3
oioldman

oioldman

    Friend of MSFN

  • Member
  • PipPipPipPipPip
  • 969 posts
  • OS:Windows 7 x64
@baywatch - That URL is bad.

@Guillaume_fr - Also, it is done via the SET HOMEPATH option.
if you open the command box and type SET then hit return.
What is your homepth, and change as needed.
"Information on the Internet is subject to the same rules and regulations as conversation at a bar" Dr George Lundberg

Search: To make a thorough examination of; look over carefully in order to find something; explore.

Antec P182 containing 8GB DDR2 Corsair & Intel Quad 6600 plugged in to Asus P5E-VM HDMI running W7 Professional

#4
Guillaume_fr

Guillaume_fr

    Newbie

  • Member
  • 13 posts
I have
HOMEDRIVE=d:
HOMEPATH=\Documents and Settings\Guillaume

If I make
> set HOMEDRIVE="C:"
> set HOMEPATH="\"
The next time I'll launch cmd.exe my HOMEDRIVE and HOMEPATH will be "d:" and "\Documents ..."

So, how can I make my changes persistants ?
And won't there have any other effects ?

#5
maxXPsoft

maxXPsoft

    MSFN Master

  • Developer
  • 2,880 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Heres what I use to make the path in the Dir it executes on.
This gives you right click on all Files/Folders and DOS HERE appears. Click it and opens the cmd prompt with path in dir of containing. That Microsoft one is useless to me.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\cmd]
@="DOS HERE"

[HKEY_CLASSES_ROOT\*\shell\cmd\command]
@="cmd.exe \\\"%1\\\""

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="DOS HERE"

[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\\\""

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="DOS HERE"

[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\\\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd]
@="DOS HERE"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd\command]
@="cmd.exe /k \"cd %L\\\""

Download ++> Windows 7 + 8 Unattended DVD + App Installer + Services Disabler + Load All Button + XML Creator
Jump2Reg - Registry: - Oct 4, 2013 - Version 3.0.4 - 98, ME, NT, 2K, XP, VISTA, Seven, Windows 8+ and 32 or 64 bit

XP Unattended CD/DVD creator - Version 4.1.7
Sample xml + Setupcomplete + Add Right click .wim Windows 7 or Windows 8/8.1

#6
maxXPsoft

maxXPsoft

    MSFN Master

  • Developer
  • 2,880 posts
  • OS:Windows 7 x64
  • Country: Country Flag
BTW if you right click on a file on the desktop it will give you what you had. Anywhere else its the actual path

E:\_beta.microsoft.com>
C:\UnattendXP>
Download ++> Windows 7 + 8 Unattended DVD + App Installer + Services Disabler + Load All Button + XML Creator
Jump2Reg - Registry: - Oct 4, 2013 - Version 3.0.4 - 98, ME, NT, 2K, XP, VISTA, Seven, Windows 8+ and 32 or 64 bit

XP Unattended CD/DVD creator - Version 4.1.7
Sample xml + Setupcomplete + Add Right click .wim Windows 7 or Windows 8/8.1

#7
Guillaume_fr

Guillaume_fr

    Newbie

  • Member
  • 13 posts
maxXPsoft, I'm already using it (And it works).

I'd like to be on C:\ when opening cmd.exe

#8
maxXPsoft

maxXPsoft

    MSFN Master

  • Developer
  • 2,880 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Hmm I tried cmdinit.bat but no joy to do that. I'm not sure then a way to get it there. You could use that above and just click the C: drive and click Dos Here. I get
C:\>
Download ++> Windows 7 + 8 Unattended DVD + App Installer + Services Disabler + Load All Button + XML Creator
Jump2Reg - Registry: - Oct 4, 2013 - Version 3.0.4 - 98, ME, NT, 2K, XP, VISTA, Seven, Windows 8+ and 32 or 64 bit

XP Unattended CD/DVD creator - Version 4.1.7
Sample xml + Setupcomplete + Add Right click .wim Windows 7 or Windows 8/8.1

#9
spiritpyre

spiritpyre

    Grand Poobah

  • Member
  • PipPip
  • 191 posts
this probably doesn't help but using /K parameter you can set the directory when you call cmd

cmd.exe /k cd "C:\"


opens cmd pointed to C:\
although if you always want cmd to point to C:\ and you use a shortcut to call cmd
you could just put that in the shortcut? just an idea

#10
rubyquyen

rubyquyen
  • Member
  • 5 posts

Hello,

When I launch cmd.exe on my XP SP2 (via Start | Run), the current directory is my Home Directory; I get this :
             Microsoft Windows XP [version 5.1.2600]
             © Copyright 1985-2001 Microsoft Corp.
            
             D:\Documents and Settings\Guillaume>

How can I set up Windows to open cmd.exe in another directory (C:\ or anything else) ?

[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
"AutoRun"="C: && cd \\"
Voilà :)

#11
Zxian

Zxian

    Scroll up - see the Google bar?

  • Super Moderator
  • 5,066 posts
  • OS:none specified
  • Country: Country Flag

[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
"AutoRun"="C: && cd \\"
Voilà :)

<{POST_SNAPBACK}>


That should read:

[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
"AutoRun"="C: && cd \"

Note the single backslash. Otherwise you get an error (surprise...:P). Thanks for this though! Very nice!

Cheers!

#12
rubyquyen

rubyquyen
  • Member
  • 5 posts

Note the single backslash. Otherwise you get an error (surprise...:P). Thanks for this though! Very nice!

Yes, single backslash if you enter the value directly into the registry. Mine is extracted from a .reg file, so double backslash are required.

#13
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

What about this?
REG ADD "HKLM\SOFTWARE\Microsoft\Command Processor" /v AutoRun /d "%%SystemDrive%%" /f
or in reg format
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]

"AutoRun"="%SystemDrive%"


#14
rubyquyen

rubyquyen
  • Member
  • 5 posts

What about this?

REG ADD "HKLM\SOFTWARE\Microsoft\Command Processor" /v AutoRun /d "%%SystemDrive%%" /f
or in reg format
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"AutoRun"="%SystemDrive%"

<{POST_SNAPBACK}>

That sounds good, except that if you want C:\mydir as default, but your system is on D:, that won't work :)

#15
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

That sounds good, except that if you want C:\mydir as default, but your system is on D:, that won't work :)

None of the examples given to date used C:\mydir. In fact if you want C:\mydir, your example(s) will not work either.
The original questioner also only asked

I'd like to be on C:\ when opening cmd.exe

Since most users C: drive is also the %SystemDrive%, I gave that as an alternative, because in that scenario you don't need the && cd etc..
If you would like to explain the probability of someone installing their system on D: and running the cmd shell, very likely located at D:\WINDOWS\system32 or D:\WINNT\system32 to access root at C:, which will very likely belong to another OS! (How many people create a 'data' drive as C: and then install the OS to D:)

In your case, (as given in your quote above), all you should need would be
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"AutoRun"="cd /d c:\\mydir"
or in a case where you have spaces in your chosen path. (The additional quotes may not be necessary if you have command extensions enabled)
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"AutoRun"="cd /d \"c:\\my dir\""
By the way, if anyone is testing these without having first backed up the key, to return to the default setting use this
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"AutoRun"=""


#16
rubyquyen

rubyquyen
  • Member
  • 5 posts

...

You're right, but I was replying to the very first message of this thread :

When I launch cmd.exe on my XP SP2 (via Start | Run), the current directory is my Home Directory; I get this :
            D:\Documents and Settings\Guillaume>

How can I set up Windows to open cmd.exe in another directory (C:\ or anything else) ?

(note that his %SystemDrive% is not C and C:\ was only given as an example)

so I was showing the way (= modify the default path and if needed the drive). IMHO, he would be capable of generalising himself the case.

The most important thing to my eyes was the registry key that, so far, nobody had pointed out. Once we got it, using .reg or reg.exe or any other ways were just a question of personal preference.

BTW, thanks for the switch /d that I didn't know. This scenario is certainly more elegant than && cd :D

#17
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

...

You're right, but I was replying to the original author of this thread :

When I launch cmd.exe on my XP SP2 (via Start | Run), the current directory is my Home Directory; I get this :
            D:\Documents and Settings\Guillaume>

How can I set up Windows to open cmd.exe in another directory (C:\ or anything else) ?

so I was giving the way (= modify the default path and if needed the drive), IMHO, he would be capable of finding himself any further customization.

The most important thing was the registry key, that so far, nobody had indicated. Afterthat, using .reg or reg.exe or any other ways were just upto your choice.

<{POST_SNAPBACK}>

Editing your posts is sometimes not a good idea!

You have now realized that you were not replying to the thread starters most recent message.

However, please do not try to correct me with guessed information, the author has in no way stated that his %SystemDrive% is anything other than C:. From the information available, the most likely scenario is that the %SystemDrive% is C: and the ProfilesDir has been set to D:\Documents and Settings\ in their winnt.sif. This may in fact be incorrect, but it is more likely.

You gave your reply, I gave mine, both work, mine is more usable to the majority of the thread readers, as are my further replies.

#18
rubyquyen

rubyquyen
  • Member
  • 5 posts

...

You're right, but I was replying to the original author of this thread :

When I launch cmd.exe on my XP SP2 (via Start | Run), the current directory is my Home Directory; I get this :
            D:\Documents and Settings\Guillaume>

How can I set up Windows to open cmd.exe in another directory (C:\ or anything else) ?

so I was giving the way (= modify the default path and if needed the drive), IMHO, he would be capable of finding himself any further customization.

The most important thing was the registry key, that so far, nobody had indicated. Afterthat, using .reg or reg.exe or any other ways were just upto your choice.

<{POST_SNAPBACK}>

Editing your posts is sometimes not a good idea!

You have now realized that you were not replying to the thread starters most recent message.

However, please do not try to correct me with guessed information, the author has in no way stated that his %SystemDrive% is anything other than C:. From the information available, the most likely scenario is that the %SystemDrive% is C: and the ProfilesDir has been set to D:\Documents and Settings\ in their winnt.sif. This may in fact be incorrect, but it is more likely.

You gave your reply, I gave mine, both work, mine is more usable to the majority of the thread readers, as are my further replies.

<{POST_SNAPBACK}>

Yes, I edited my message (one of the most important reasons is to correct my bad English that I was afraid not to be enough clear to express my idea), but from the first version (of that message), I already said that I replied to the first post of the thread. That's the reality (see my post on May 14 2005, 02:18 AM).

I don't know if Guillaume's winnt.sif had been configured to move the profile folders to another partition, you're like right. I didn't think about this possibility because my current system drive is on E.

I insist that I gave the way (= modify the default path and if needed the drive) and don't impose any choice (one should be capable of replacing C with any drive of his choice, and \ with any directory). Your reply on May 16 2005, 02:30 PM is perfect (cd /d C:\mydir), but the previous one IMHO is much less (I don't thinks %SystemDrive% is a generic solution in this particular case).

You shouldn't take the fact that one says your reply is not a general solution as a personal attack (at least in this case) and be nervous for that. Keep cool ! We're here to exchange experience, that's all ! I could be forever a simple reader if somebody had given the answer to that question (note that the thread was opened on May 3rd). So I said to myself : I know it, why not contribute my little knowledge to express my thankfulness for many things I learnt from them ? I'm new to this forum that I discovered some days before, but that doesn't mean I never frequent any other one in other languages and don't know that many different solutions may resolve a single problem. I'm really being disappointed.

#19
spiritpyre

spiritpyre

    Grand Poobah

  • Member
  • PipPip
  • 191 posts
not trying to get flamed or anything but IMHO that was a pretty pointless argument (both ways are valid and both can be modified by most people who are willing to actually look at the code)

... So I said to myself : I know it, why not contribute my little knowledge to express my thankfulness for many things I learnt from them ? I'm new to this forum that I discovered some days before...


Thanks you for posting and welcome :D

btw sorry for the late post (just remembered about the thread and thought i'd check back to see how weak everybody made my earlier post look.. :P )

Edited by spiritpyre, 06 June 2005 - 09:50 PM.


#20
matthewk

matthewk

    Member

  • Member
  • PipPip
  • 288 posts
I just made this from the above posts. Thanks for the info. I'm not sure if this will be helpful. I put in batch file then converted the batch to exe with http://www.computerh...ity/bat2exe.com . Then, placed the cmd.com in %windir%\system32.
ex. start->run, cmd c:\xpcd
Here are the bat contents
call cmd.exe /k cd "%1"\
Here is the cmd.com http://onyx.cs.olemi...akoosha/cmd.com

#21
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

@ matthewk
Quite a clever alternative.

I've now done something similar, it's essentially the same with my code and a little added error trappingIf you type an invalid directory, it should open the prompt in the usual manner.
I was going to post it, but for some reason the attachment option appears to have left the forum!

#22
spiritpyre

spiritpyre

    Grand Poobah

  • Member
  • PipPip
  • 191 posts

@ matthewk
Quite a clever alternative.

I've now done something similar, it's essentially the same with my code and a little added error trappingIf you type an invalid directory, it should open the prompt in the usual manner.
I was going to post it, but for some reason the attachment option appears to have left the forum!

<{POST_SNAPBACK}>


I had a similar problem a while back and Alanoll recommended www.eazyshare.com. have to say works pretty good.

Edited by spiritpyre, 15 June 2005 - 10:19 PM.


#23
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

Well it appears that it's just an option not available in this particular forum area.

I wonder what would happen if I were to deliberately post it in a different forum area, and wait for the Mods to move it?

#24
2forza

2forza

    "everybody was kungfu fighting"

  • Member
  • PipPip
  • 230 posts
Maybe its offtopic:

How do you copy with mouse only? By selecting it and rightmouse button to copy
Like in the Linux,

Thought it was also added @ XPIZE CMD prompt,

greetings forzA,
Dell XPS M1530 | Intel Core2 Duo T7700 2.40 GHz | GeForce Go 8600M GT | 2GB DDR2 SDRAM

#25
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,530 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

@ 2forza - Is this what you mean?
[HKEY_CURRENT_USER\Console]

"QuickEdit"=dword:00000001





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN