darksimoon Posted August 26, 2005 Posted August 26, 2005 hi friends i want to chance the default place of my temp folders and then delete previous temp folders and clean new temp folderto do this, i have wrote a cmd file as follows=========newtemp.cmd=================md %systemdrive%\temprd /s /q "%userprofile%\Local Settings\Temp"rd /s /q "%systemdrive%\Documents and Settings\Administrator\Local Settings\Temp"rd /s /q "%systemdrive%\Documents and Settings\Default User\Local Settings\Temp"rd /s /q "%systemroot%\temp"reg add newtemp.regDEL /F /S /Q "%systemdrive%\TEMP\*.*"==========================and a reg file to chance the default places for temp folders========newtemp.reg==================Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]"TEMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,\ 00,65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00"TMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,00,\ 65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]"TEMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,\ 00,65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00"TMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,00,\ 65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager\Environment]"TEMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,\ 00,65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00"TMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,00,76,00,\ 65,00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00[HKEY_CURRENT_USER\Environment]"TEMP"="%systemdrive%\\Temp""TMP"="%systemdrive%\\Temp"==========================here is the question; instead of applying registry entries with the "reg add newtemp.reg" command from my batch file, why not write it inside my newtemp.cmd file like runonceex.cmd ? in this way one cmd file is enough both cleaning temp folders and chancing the default temp folders. but i dont know how to do that. i tried to do it by learning the parameters from reg add /? in a cmd window but it didnt work. it allways give me "too many parameters" error. pls show me a general info and example so that i can do it by myself... thanks in advance.
Doc Symbiosis Posted August 26, 2005 Posted August 26, 2005 (edited) To apply a regfile, you have to use the reg import command. So in your runonceex.cmd you should use the command "reg add newtemp.reg".A little better would be to use this line in your cmdlines.txt, cause when it is executed there, no user except the default user exists and so the HKCU entries are taken for the default user, also for the user you run the runonceex with. Edited August 26, 2005 by Doc Symbiosis
Yzöwl Posted August 26, 2005 Posted August 26, 2005 @ darksimoonIn your example, you need to changereg add newtemp.reg to regedit /s newtemp.regHere is a way you can redirect the 'user temp' folders to the same location as '\WINDOWS\Temp' for everyone at once with no requiremrnt to remove them later in your cleanup routine. Use this in cmdlines.txt@Echo off&Pushd %UserProfile%\..\Default UserReg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :EofReg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulReg add HKU\TempHiv\Environment /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul:Un_Reg unload HKU\TempHiv>Nul 2>&1||Goto Un_Although this is not what you require, it shows you the REG ADD syntax you can use and a method of applying current user registry entries to all users.
matthewk Posted August 28, 2005 Posted August 28, 2005 (edited) Here is a way you can redirect the 'user temp' folders to the same location as '\WINDOWS\Temp' ...<{POST_SNAPBACK}>Is this alike the option that is available in nlite? I was curious incase I needed to do look into this way of changing it myself to the temp folder like you showed. Thanks Edited August 28, 2005 by matthewk
darksimoon Posted September 10, 2005 Author Posted September 10, 2005 hello yzwölhow are you friend? i tried the cmd file you provide me but it didnt work and gave me error in a way that "wrong parameter" that occurs twice at the same window. in order to determine the fault, i made a new cmd file which contains just these lines:code====================================Reg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\Temp" /f>NulReg add HKU\TempHiv\Environment /v TMP /t REG_EXPAND_SZ /d "%%SYSTEMROOT%%\Temp" /f>Nul====================================and the result is same. i mean the fault must be somewhere here. can you help me pls about it. and meanwhile i want to assign all temp and tmp folders to %systemdrive% not %systemroot% in order to avoid defragmentation in the system folder. pls help me about it or correct me if i am wrong... thanks in advance @matthewkhey friend thanks for your help. as amatter of fact i want to do it in unattended way. but it might be helpfull by registry snapping method. but this is my last alternative..
Bilou_Gateux Posted September 10, 2005 Posted September 10, 2005 @Echo off&Pushd %UserProfile%\..\Default UserReg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :EofReg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulReg add HKU\TempHiv\Environment /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul:Un_Reg unload HKU\TempHiv>Nul 2>&1||Goto Un_Can you explain the double pipe || in your batch script.
Yzöwl Posted September 10, 2005 Posted September 10, 2005 (edited) Try this instead!@Echo offReg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulReg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulPushd %UserProfile%\..\Default UserReg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :EofReg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulReg add HKU\TempHiv\Environment /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul:Un_Reg unload HKU\TempHiv>Nul 2>&1||Goto Un_@darksimoonJust change the %SystemRoot% to %SystemDrive% etc. as necessary for your purposes.<Edit>Bilou the double pipe just means 'if unsuccessful then'</Edit> Edited January 22, 2008 by Yzöwl code tags fixed for easier to read code
darksimoon Posted October 13, 2005 Author Posted October 13, 2005 @Yzöwlhello Yzöwl, how are you ? i hope you're in a good mood. friend, i have tried your batch file but it gave an error message called "too many parameters" i opened it to understand and categorized (in order to understand easly and tidy since the copy/paste has made it untidy) but it looks allright. nothing seems wrong. i also examine and compared your batch file about superhidden files.So i have decided to send you the batch file itself in order to prevent misunderstanding. can you check and correct it for me please ? i dont want to tire you and i have done my best. as a last solution i am applying you.thanks in advance temp_tidied_.cmd
nakira Posted October 13, 2005 Posted October 13, 2005 You need to add quotes around the first two key names as they have a space in themReg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>NulREG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Yzöwl Posted October 13, 2005 Posted October 13, 2005 Well spotted, thank you!I have adjusted my postings to suit.
darksimoon Posted October 14, 2005 Author Posted October 14, 2005 @nakira@Yzöwlthanks friends my UACD is getting well day by day thanks to you...
Quisquose Posted March 7, 2007 Posted March 7, 2007 I'm trying to do the exact opposite on my Windows 2000 install.Although each user does have a Temp folder (located in the Local Settings folder of their user account) there is still a useless Temp folder in C:\Windows that I would like to get rid of. I can't just delete the folder using a batch file because it's considered "in use" due to the two Session manager environment Registry keys that define TEMP and TMP as %SystemRoot%\TEMP.If I just go through and replace all instances of %%SystemRoot%%\TEMP with %%USERPROFILE%%\Local Settings\Temp in Yzöwl's cmdlines.txt example, will it prevent the creation of the %SystemRoot%\TEMP reg key and C:\Window\Temp folder so that I don't have to subsequently delete them?
glachu87 Posted June 21, 2010 Posted June 21, 2010 Hi Friend, First of all I am not a computer savvy like you. I have a silly doubt. I am trying to add and delete some registry keys so wat I did was I typed (((((reg add "hklm\system\currentcontrolset\control\session manager\PendingFileRenameOperations" /freg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /f))))))) this in a notepad. Can u please tell me how to execute this? I mean wat I am trying to do is if I click on that file it should create an entry in registry.Thanxs in AdvanceFrom Laxmi.
jaclaz Posted June 21, 2010 Posted June 21, 2010 this in a notepad.Why all those brackets? Have in Notepad:@ECHO OFFECHO reg add "hklm\system\currentcontrolset\control\session manager\PendingFileRenameOperations" /freg add "hklm\system\currentcontrolset\control\session manager\PendingFileRenameOperations" /fPAUSEECHO reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /freg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /fPAUSEsave the file as "all files" manually giving it a .cmd extension.Double click on it.If it does what you want, you can remove the ECHO lines and the PAUSE statements allright.Please NOTE that the board software wrap arounds long lines, make sure that the lines that seem like beginning with "Auto Update" are actually the "tail of the preceding line.jaclaz
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now