Jump to content

Recommended Posts

Posted (edited)

echo HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254,"Installed",0x10001,1 >>entries_KB975254.ini
echo HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254,"Comments",0,"Security Update for Windows XP (KB975254)">>entries_KB975254.ini

On the first line I have to add a space between 1 >> or it will drop the 1.

Anyone know why this is and if there is a way to do it without adding a space?

Thanks!

EDIT: It also chokes on % characters.

For example...

echo Base.AppDir.Mui.CopyFile= 16422,%MSIE4%\%MuiCultureDirectory%>file.txt

comes out like this...

Base.AppDir.Mui.CopyFile= 16422,\

Edited by -X-

Posted

(echo HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254,"Installed",0x10001,1)>>entries_KB975254.ini
(echo Base.AppDir.Mui.CopyFile= 16422,%%MSIE4%%\%%MuiCultureDirectory%%)>>entries_KB975254.ini

This code should work. The usual dos escape character (^) didn't work with the "%" and in these cases, doubling the character works.

Posted

When you redirect output, you can chose to redirect STDERR and/or STDOUT.

STDERR is redirected thus 2>erroutput.log STDOUT is redirected 1>output.log, the 1 is assumed as default.

The problem is that it appears to the command parser as if you've included the 1; and because it was assumed it was therefore dropped, (removed).

It would be good practice to always include it and/or always include the space.

ECHO=HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254","Installed",0x10001,1 1>>entries_KB975254.ini
ECHO=HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254","Comments",,"Security Update for Windows XP (KB975254)" 1>>entries_KB975254.ini

My preference is to move the redirection to the other end of the command line

@ECHO OFF
SETLOCAL
SET "HFKEY=SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix"
>entries_KB975254.ini (
ECHO=HKLM, "%HFKEY%\KB975254", "Installed", 0x10001, 1
ECHO=HKLM, "%HFKEY%\KB975254", "Comments", ,^
"Security Update for Windows XP (KB975254)"
)

Posted

Another way to add the redirect is to place it just after ECHO.

echo>>entries_KB975254.ini HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254,"Installed",0x10001,1
echo>>entries_KB975254.ini HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB975254,"Comments",0,"Security Update for Windows XP (KB975254)"

echo>file.txt Base.AppDir.Mui.CopyFile= 16422,%%MSIE4%%\%%MuiCultureDirectory%%

Posted (edited)

Using double quotes is good general practice, but is not strictly necessary unless dealing directly with registry hive files. In that case, datatypes should not be omitted or abbreviated: 0 should be 0x00000000 and 0x10001 should be 0x00010001. [strings] sections should also be avoided in hive files. Extra spaces around comma delimiters may also be problematic.

Edited by 5eraph

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...