This doesn't work: CD folder & ECHO %CD%
Moderator: DosItHelp
-
- Posts: 6
- Joined: 26 Feb 2010 10:38
This doesn't work: CD folder & ECHO %CD%
I am using this command: CD folder & ECHO %CD%
I need to do this in one line! But it doesn't work? Why not? How can i do this?
Output:
C:\>cd Folder & echo %CD%
C:\ <-THIS IS NOT OK FOR ME - it should be C:\Folder
C:\Folder>
Please help
I need to do this in one line! But it doesn't work? Why not? How can i do this?
Output:
C:\>cd Folder & echo %CD%
C:\ <-THIS IS NOT OK FOR ME - it should be C:\Folder
C:\Folder>
Please help
Re: This doesn't work: CD folder & ECHO %CD%
It doesn't work if you change the directory and show the new directory name in the same line. Why don't you use two lines?
If you work with a batch file there is a trick
If you work with a batch file there is a trick
Code: Select all
cd Folder &call echo %%CD%%
-
- Posts: 6
- Joined: 26 Feb 2010 10:38
Re: This doesn't work: CD folder & ECHO %CD%
I am not using two lines, because i call this command from Delphi.
Is there no other way?
Code: Select all
CreateProcess(nil, PChar('cmd.exe /C ' + cmdLine), nil, nil, True, 0, nil, PChar(WorkDir), SI, PI);
Is there no other way?
Re: This doesn't work: CD folder & ECHO %CD%
You could try to use the delayed expansion of variables.
Note that it doesn't work without the quotes.
Hope it will work. I have no idea of Delphi.
Code: Select all
cmd /v:on /c "cd Folder&echo !cd!"
Note that it doesn't work without the quotes.
Hope it will work. I have no idea of Delphi.
-
- Posts: 6
- Joined: 26 Feb 2010 10:38
Re: This doesn't work: CD folder & ECHO %CD%
It works perfect. I have to call the same function in Delphi, but no problem. First to do it, second to echo new dir Thanks! U really helped me a lot!
-
- Posts: 6
- Joined: 26 Feb 2010 10:38
Re: This doesn't work: CD folder & ECHO %CD%
Another problem. When i open a picture like picture.gif, the program freezes until i close the picture viewer. In linux you can get rid of this by adding & on the end ... but on windows... doesn't work.
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: This doesn't work: CD folder & ECHO %CD%
Could do:
cd folder & call echo %%cd%%
cd folder & call echo %%cd%%
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: This doesn't work: CD folder & ECHO %CD%
drinovc.copy wrote:Another problem. When i open a picture like picture.gif, the program freezes until i close the picture viewer. In linux you can get rid of this by adding & on the end ... but on windows... doesn't work.
Use the "start" command to start something without waiting for it to finish.