Jump to content

Recommended Posts

Posted

Guys, can you tell me where exactly do I NEED to use double backslashes please? I tried to google it up and didn't get any definite answer. I never used it once and never had a problem. Various sources say I MUST use double backslashes in scripts, but that's quite general statement. Never had problems using single backslash in .reg files, batch files, or unattended one.


Posted

Well it depends on the context but generally speaking that is the syntax that an application needs to properly parse the input.

Posted

Hm. I always used it in batch files and .reg files without problems. Never used it in unattended answer file either. Everything always worked...

Posted

It's more a factor of what other pieces of software are involved - not just batch and .reg files by themselves which in general do not require double backslashes. There are other utilities that use the backslash as an escape character. For example, you might have seen references to "\n" being used to represent a "new line"? This is true in all the various versions of C, C++, etc. Anyway, since the backslash is used as an escape character, then if you really wanted to use a backslash as a backslash, you have to double it up, ie escape the escape character. I usually see doubled backslashes used for code that is run during Windows installation routines, since many of those routines are written in C++. But someone else will need to give you better specifics. I can just tell you the "why", not the "when". Sorry.

Cheers and Regards

Posted
Various sources say I MUST use double backslashes in scripts

Can you name a example?

Never had problems using single backslash in .reg files,

A Reg_sz entry uses double backslashes at path.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Browser]
"DisplayName"="@%systemroot%\\system32\\browser.dll,-100"

batch files
A regular expression search string may use double backslashes to escape a single backslash

http://technet.microsoft.com/en-us/library/bb490907.aspx

Posted

Can't name any specific, just people on forums and articles I read in past...

Fair enough with the registry, but why does it work with single backslash as well?

example:

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Themes /v InstallTheme /t REG_SZ /d "%SystemDrive%\Windows\Resources\Themes\AeroNoBackground.theme" /f

Posted
why does it work with single backslash as well?

This example uses reg.exe to set a entry.

Reg.exe is another application with own rules: single backslash is appropiate

This is not a .reg file.

Posted (edited)

if I export a reg key and it has the \\ then I simply use that.

Here is perfect example where if you don't then it won't work.

First reg file that works

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Kill Not Responding Tasks\command]
@="C:\\Windows\\System32\\taskkill.exe /F /FI \"STATUS eq NOT RESPONDING\""

Now we remove \\ and it say it import but you open key and it is blank

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Kill Not Responding Tasks\command]
@="C:\Windows\System32\taskkill.exe /F /FI \"STATUS eq NOT RESPONDING\""

EDIT: You must delete key before second import to see this

Case closed?

Edited by maxXPsoft
Posted

Now I understand, I guess you need to use the double backslash for setting theme registry as the default registry is like this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes]
"Drop Shadow"="FALSE"
"Flat Menus"="FALSE"
"SetupVersion"="10"
"InstallTheme"="C:\\Windows\\resources\\Themes\\aero.theme"
"InstallVisualStyle"="%ResourceDir%\\themes\\Aero\\Aero.msstyles"

Posted

Now I understand, I guess you need to use the double backslash for setting theme registry as the default registry is like this:

I had not tampered with that theme key but I exported same key and it does contain \\ as default.

There are certain keys that won't work unless you \\. I have no explanation but if you export and they contain then you best use them.

Posted
Now I understand, I guess you need to use the double backslash for setting theme registry as the default registry is like this:

It's not about theme.

It's about a file name with a path. This goes to all folder file names.

"InstallVisualStyle"="%ResourceDir%\\themes\\Aero\\Aero.msstyles"

Seems to be a default bug: a RegSz dosn't expand a %ResourceDir% entry.

Posted (edited)

Seems to be a default bug: a RegSz dosn't expand a %ResourceDir% entry.

hadn't noticed that till you said something.

Type set in a cmd prompt. There is no %ResourceDir%

Google returns nothing on it either

MS Bug for sure.

Edited by maxXPsoft
Posted (edited)

%ResourceDir% is internal Windows thing. Doing a file content search I find this in many files.

post-9484-0-88185000-1333957738_thumb.pn

Edited by maxXPsoft
Posted

I don't doubt %ResourceDir%. I doubt the type Reg_SZ.

A XP themeui.dll sets

HKLM,"Software\Microsoft\Windows\CurrentVersion\Themes\VisualStyleDirs","1",%REGEXSZ%,"%%ResourceDir%%\Themes"

This setting exist at Windows 7 too.

That's type Reg_Expand_SZ to %ResourceDir%.

Can anybody clarify this?

Which part uses %ResourceDir% ? Which part expand the string?

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