MSFN Forum: help for "reg add" command in *.cmd - MSFN Forum

Jump to content


Unattended CD/DVD Guide Homepage · MSFN Forum Rules

If you have questions about customizing Windows XP that are nLite-specific, please post them in the nLite forum, not here. If you have questions regarding the unattended installation of Windows XP, please post them in the Unattended Windows 2000/XP/2003 section.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

help for "reg add" command in *.cmd apply registry entries by cmd files Rate Topic: -----

#1 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 29-May 05

  Posted 26 August 2005 - 04:17 AM

hi friends :hello:

i want to chance the default place of my temp folders and then delete previous temp folders and clean new temp folder
to do this, i have wrote a cmd file as follows
=========newtemp.cmd=================
md %systemdrive%\temp
rd /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.reg

DEL /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.


#2 User is offline   Doc Symbiosis 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 333
  • Joined: 03-August 04

Posted 26 August 2005 - 06:49 AM

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.

This post has been edited by Doc Symbiosis: 26 August 2005 - 06:52 AM


#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 26 August 2005 - 07:53 AM

@ darksimoon
In your example, you need to change
    reg add newtemp.reg to regedit /s newtemp.reg
Here 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 User
Reg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :Eof
Reg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Reg 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.

#4 User is offline   matthewk 

  • Member
  • PipPip
  • Group: Members
  • Posts: 288
  • Joined: 07-June 05

Posted 28 August 2005 - 01:02 PM

Yzöwl, on Aug 26 2005, 07:53 AM, said:

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
Posted Image

This post has been edited by matthewk: 28 August 2005 - 01:11 PM


#5 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 29-May 05

Posted 10 September 2005 - 04:08 AM

hello yzwöl
how 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>Nul
Reg 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 :)

@matthewk
hey 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..

#6 User is offline   Bilou_Gateux 

  • Powered by Windows Embedded
  • PipPipPipPipPip
  • Group: Members
  • Posts: 766
  • Joined: 03-January 04

Posted 10 September 2005 - 04:28 AM

Yzöwl, on Aug 26 2005, 07:53 AM, said:

@Echo off&Pushd %UserProfile%\..\Default User
Reg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :Eof
Reg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Reg 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.

#7 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 10 September 2005 - 04:49 AM

Try this instead!
 
@Echo off
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Pushd %UserProfile%\..\Default User
Reg load HKU\TempHiv NTUSER.DAT>Nul 2>&1||Goto :Eof
Reg add HKU\TempHiv\Environment /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
Reg 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_ 
@darksimoon
Just change the %SystemRoot% to %SystemDrive% etc. as necessary for your purposes.
<Edit>
Bilou the double pipe just means 'if unsuccessful then'
</Edit>

This post has been edited by Yzöwl: 22 January 2008 - 11:32 AM
Reason for edit: code tags fixed for easier to read code


#8 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 29-May 05

Posted 13 October 2005 - 05:51 AM

@Yzöwl

hello 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 :)

Attached File(s)



#9 User is offline   nakira 

  • Member
  • PipPip
  • Group: Members
  • Posts: 118
  • Joined: 18-July 04

Posted 13 October 2005 - 08:09 AM

You need to add quotes around the first two key names as they have a space in them
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul
REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d "%%SystemRoot%%\Temp" /f>Nul


#10 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,369
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 13 October 2005 - 08:55 AM

Well spotted, thank you!

I have adjusted my postings to suit.

#11 User is offline   darksimoon 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 29-May 05

Posted 14 October 2005 - 05:33 AM

@nakira
@Yzöwl
thanks friends :) my UACD is getting well day by day thanks to you...

#12 User is offline   Quisquose 

  • Junior
  • Pip
  • Group: Members
  • Posts: 59
  • Joined: 19-November 06

  Posted 07 March 2007 - 08:32 AM

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?

#13 User is offline   glachu87 

  • Group: Members
  • Posts: 1
  • Joined: 20-June 10
  • OS:none specified
  • Country: Country Flag

Posted 20 June 2010 - 06:09 PM

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" /f
reg 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 Advance
From Laxmi.

#14 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,574
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 21 June 2010 - 02:42 AM

View Postglachu87, on 20 June 2010 - 06:09 PM, said:

this in a notepad.


Why all those brackets? :unsure:

Have in Notepad:
@ECHO OFF
ECHO reg add "hklm\system\currentcontrolset\control\session manager\PendingFileRenameOperations" /f
reg add "hklm\system\currentcontrolset\control\session manager\PendingFileRenameOperations" /f
PAUSE
ECHO reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" /f
PAUSE


save 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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy