March 17, 200521 yr 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.
March 17, 200521 yr 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.
March 17, 200521 yr 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
March 17, 200521 yr Author I have just found the solution:%winbootdir%.\cd %winbootdir%It works perfectly...
March 17, 200521 yr 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.
March 18, 200521 yr Author Thanks tentonine,It's a very good batch file, maybe I'll use it later. For RC2, I think my solution is enough.
Create an account or sign in to comment