Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

Topic # 60646 29-Apr-2010 14:21
Send private message

Having trouble trying to import a string into the registry via a reg file when the string cointains EOL makers.

The key is HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system
The value is LegalNoticeText

This can be set via gpedit (Computer Configuration\Windows Settigns\Security Settings\Local Policies\Security Options\Interactive Login: Message text for users atetmpting to log on).

I can set a multiline, formatted string via gpedit with no problems. PC shows the correctly formatted string when users attempt to login. I can export that string via regedit, and it exports to a .reg fine. If I then delete the key, and try and import it, it fails to the the multi line nature. I've tried using both the default export, and manually editing the file so it's a single line with EOL markers in it. When viewed in regedit, the value (when its as it should be after beign set with gpedit) shows it as a single line with two of those little squares you see when it cant recognise/display the character. A hexedit of the export file shows that as being standard CR/LF.

Does anyone know of a way for me to import a multi line string into the registry via a .reg file that will work?

This is stumping me and pissing me off :-)





Information wants to be free. The Net interprets censorship as damage and routes around it.


Create new topic
8027 posts

Uber Geek
+1 received by user: 387

Trusted
Subscriber

  Reply # 324730 29-Apr-2010 14:36
Send private message

Can you use carriage return new line special characters instead, eg: for new line \n and carriage return \r

So where you want the line break use something like:

="My First Line\r\nMy Second Line"




3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 324738 29-Apr-2010 14:43
Send private message

Tried it, doesnt like it. Cheers for teh suggestion thou.
"legalnoticetext"="Stuff" = works
"legalnoticetext"="Stuff \r\n Other Stuff" = fail






Information wants to be free. The Net interprets censorship as damage and routes around it.




3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 324740 29-Apr-2010 14:45
Send private message

Also fail:

"legalnoticetext"="Stuff
Other Stuff"

"legalnoticetext"="Stuff *inserted ascii here*Other Stuff"




Information wants to be free. The Net interprets censorship as damage and routes around it.


3290 posts

Uber Geek
+1 received by user: 209

Trusted

  Reply # 324745 29-Apr-2010 14:48
Send private message

Could you use a .vbs or something instead?

e.g.

Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")

Title = "Caption"
Text = "Line 1" & VbCrLf & "Line 2" & VbCrLf & "Line 3"

WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\LegalNoticeCaption", Title, "REG_SZ"
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\LegalNoticeText", Text, "REG_SZ"

n.b. I didn't try this myself...



3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 324754 29-Apr-2010 14:56
Send private message

bazzer: my vb skills are abysmal but if I cant figure out a way via a .reg file i did plan to try that.





Information wants to be free. The Net interprets censorship as damage and routes around it.


3290 posts

Uber Geek
+1 received by user: 209

Trusted

  Reply # 324764 29-Apr-2010 15:04
Send private message

I tried the above and it did work. It's a pretty straight forward script, so should be OK? Maybe .vbs doesn't feel as "safe" as .reg file? You can see the script doesn't do anything untoward.

I'm interested in your solution too. I wonder if it's a bug? I did find reference to /r being used for carriage return, but that doesn't seem to work. Maybe using hex?

3290 posts

Uber Geek
+1 received by user: 209

Trusted

  Reply # 324767 29-Apr-2010 15:05
Send private message

Eureka!

With a bit of playing around, I discovered that \n is the code you need to use. This inserts the CR/LF combo.



3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 324788 29-Apr-2010 15:37
Send private message

Bazzer: so you succesfully imported a reg file using \r? or via vbs?





Information wants to be free. The Net interprets censorship as damage and routes around it.


3290 posts

Uber Geek
+1 received by user: 209

Trusted

  Reply # 324853 29-Apr-2010 17:33
Send private message

Neither. Well, the .vbs did work to as I mentioned in #324764, but as I said in #324767 you need to use \n rather than \r in the .reg file.



3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 325003 29-Apr-2010 22:15
Send private message

bazzer: Neither. Well, the .vbs did work to as I mentioned in #324764, but as I said in #324767 you need to use \n rather than \r in the .reg file.


I meant \n lol.. Cheers will try in the morning.




Information wants to be free. The Net interprets censorship as damage and routes around it.




3454 posts

Uber Geek
+1 received by user: 1916

Trusted
Lifetime subscriber

  Reply # 325249 30-Apr-2010 13:38
Send private message

I still couldnt get it working with \n, but theVB works fine so will use that. Cheers for the help.




Information wants to be free. The Net interprets censorship as damage and routes around it.


Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.