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.




3625 posts

Uber Geek
+1 received by user: 2122

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
8029 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"




3625 posts

Uber Geek
+1 received by user: 2122

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.


 
 
 
 




3625 posts

Uber Geek
+1 received by user: 2122

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.


3295 posts

Uber Geek
+1 received by user: 210

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



3625 posts

Uber Geek
+1 received by user: 2122

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.


3295 posts

Uber Geek
+1 received by user: 210

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?

3295 posts

Uber Geek
+1 received by user: 210

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.



3625 posts

Uber Geek
+1 received by user: 2122

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.


3295 posts

Uber Geek
+1 received by user: 210

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.



3625 posts

Uber Geek
+1 received by user: 2122

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.




3625 posts

Uber Geek
+1 received by user: 2122

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


Donate via Givealittle


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:





News »

Amazon introduces new Kindle with adjustable front light
Posted 21-Mar-2019 20:14


A call from the companies providing internet access for the great majority of New Zealanders, to the companies with the greatest influence over social media content
Posted 19-Mar-2019 15:21


Two e-scooter companies selected for Wellington trial
Posted 15-Mar-2019 17:33


GeForce GTX 1660 available now
Posted 15-Mar-2019 08:47


Artificial Intelligence to double the rate of innovation in New Zealand by 2021
Posted 13-Mar-2019 14:47


LG demonstrates smart home concepts at LG InnoFest
Posted 13-Mar-2019 14:45


New Zealanders buying more expensive smartphones
Posted 11-Mar-2019 09:52


2degrees Offers Amazon Prime Video to Broadband Customers
Posted 8-Mar-2019 14:10


D-Link ANZ launches D-Fend AC2600 Wi-Fi Router Protected by McAfee
Posted 7-Mar-2019 11:09


Slingshot commissions celebrities to design new modems
Posted 5-Mar-2019 08:58


Symantec Annual Threat Report reveals more ambitious, destructive and stealthy attacks
Posted 28-Feb-2019 10:14


FUJIFILM launches high performing X-T30
Posted 28-Feb-2019 09:40


Netflix is killing content piracy says research
Posted 28-Feb-2019 09:33


Trend Micro finds shifting threats require kiwis to rethink security priorities
Posted 28-Feb-2019 09:27


Mainfreight uses Spark IoT Asset Tracking service
Posted 28-Feb-2019 09:25



Geekzone Live »

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


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



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.