Gape Posted March 17, 2005 Share Posted March 17, 2005 I want to change directory in addition to changing folder.This is possible on the Windows 2000/XP with "/d" parameter.cd /d %winbootdir%How can I do same thing on Windows 98?Thx. Link to comment Share on other sites More sharing options...
tguy Posted March 17, 2005 Share Posted March 17, 2005 You could use this method to change to the boot directory:cd\cd %SYSTEMROOT%Not sure if it will work on Win 98 but you could try it. Link to comment Share on other sites More sharing options...
tentonine Posted March 17, 2005 Share Posted March 17, 2005 GapeThis wiil give change drive and directory functions in script.@echo off:: create change drive and directory bat:: before changing drive and directory execute pushd.bat:: then execute cdd.bat when finished and you wish to return execute popd.batecho @echo off > %windir%\cdd.batecho %%1\ >> %windir%\cdd.batecho cd %%1 >> %windir%\cdd.bat:: create pushd.bat and popd.batecho %%"%% echo e 100 "cdd " >%temp%\script.txt %%"%% > %windir%\pushd.batecho %%"%% echo rcx>>%temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% echo 4>>%temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% echo n %windir%\popd.bat>>%temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% echo w >> %temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% echo q >>%temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% debug <%temp%\script.txt > NUL %%"%% >> %windir%\pushd.batecho %%"%% del %temp%\script.txt %%"%% >> %windir%\pushd.batecho %%"%% truename | find ":" >> %windir%\popd.bat %%"%% >> %windir%\pushd.bat Add the above to begining of script.Creates cdd.bat and pushd.bat.Pushd.bat will create popd.bat each time it's called.call %windir%\pushd.batcall cdd %windir%:: do somthing here:: for exampledir/a/ogen:: return to original drive and directorycall %windir%\popd.batA sample usage above. Each time you need it call pushd.bat first,then call cdd.bat. Do what you need to do then call popd.bat.:: when all done clean updel %windir%\pushd.batdel %windir%\popd.batdel %windir%\cdd.batAt end of script use above.credits:cdd.bathttp://home7.inet.tele.dk/batfiles/main/tricktip.htmpushd.bat(modified to use cdd.bat)http://www.ericphelps.com/batch/samples/pushpath.bat.txt Link to comment Share on other sites More sharing options...
Gape Posted March 17, 2005 Author Share Posted March 17, 2005 I have just found the solution:%winbootdir%.\cd %winbootdir%It works perfectly... Link to comment Share on other sites More sharing options...
tentonine Posted March 17, 2005 Share Posted March 17, 2005 GapeYes it's the same as the cdd.bat above.The rest of the code gives the ability to return to the starting directoryacross drive and directory. Thought it might be usefull if the service packwas launched from a drive other than c:.The period after %winbootdir% is not needed. Link to comment Share on other sites More sharing options...
Gape Posted March 18, 2005 Author Share Posted March 18, 2005 Thanks tentonine,It's a very good batch file, maybe I'll use it later. For RC2, I think my solution is enough. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now