Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

help for "reg add" command in *.cmd

- - - - -

  • Please log in to reply
13 replies to this topic

#1
darksimoon

darksimoon

    Member

  • Member
  • PipPip
  • 111 posts
  • Joined 29-May 05
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.
Darksimoon


How to remove advertisement from MSFN

#2
Doc Symbiosis

Doc Symbiosis

    Advanced Member

  • Member
  • PipPipPip
  • 333 posts
  • Joined 03-August 04
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 by Doc Symbiosis, 26 August 2005 - 06:52 AM.


#3
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,546 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

@ darksimoon
In your example, you need to changereg 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
matthewk

matthewk

    Member

  • Member
  • PipPip
  • 288 posts
  • Joined 07-June 05

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

Edited by matthewk, 28 August 2005 - 01:11 PM.


#5
darksimoon

darksimoon

    Member

  • Member
  • PipPip
  • 111 posts
  • Joined 29-May 05
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..
Darksimoon

#6
Bilou_Gateux

Bilou_Gateux

    Powered by Windows Embedded

  • Member
  • PipPipPipPipPip
  • 768 posts
  • Joined 03-January 04

@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.
OS Version = 5.1.2600 Service Pack 3
Platform ID = 2 (NT)
Service Pack = 3.0
Suite = 0x0140
Product Type = 1
Architecture = x86

#7
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,546 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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>

Edited by Yzöwl, 22 January 2008 - 11:32 AM.
code tags fixed for easier to read code


#8
darksimoon

darksimoon

    Member

  • Member
  • PipPip
  • 111 posts
  • Joined 29-May 05
@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 Files


Darksimoon

#9
nakira

nakira

    Member

  • Member
  • PipPip
  • 118 posts
  • Joined 18-July 04
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
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,546 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

Well spotted, thank you!

I have adjusted my postings to suit.

#11
darksimoon

darksimoon

    Member

  • Member
  • PipPip
  • 111 posts
  • Joined 29-May 05
@nakira
@Yzöwl
thanks friends :) my UACD is getting well day by day thanks to you...
Darksimoon

#12
Quisquose

Quisquose

    Junior

  • Member
  • Pip
  • 59 posts
  • Joined 19-November 06
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
glachu87

glachu87
  • Member
  • 1 posts
  • Joined 20-June 10
  • OS:none specified
  • Country: Country Flag
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
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,593 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users