Sign in to follow this  
Followers 0
new2daauto

Registry value manipulation

19 posts in this topic

Hi all, so far I find this Forum great and AutoIT as well. I'm new to programming so please excuse me. I Need some help please, I would like to not only move 1 part to the front like explained over here, I would like 2 specific parts moved to the front and second Position and 2 parts moved to the back, last and second last Position, everything (if there is more) should stay in the middle as is.

For example, I have in the registry key "HKLMSYSTEMCurrentControlSetControlNetworkProviderOrder - ProviderOrder" this value;

NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs

but I want it to look like this;

LanmanWorkstation,RDPNP,webclient,vmhgfs,NCFSD,Cwbnetnt

I Need "LanmanWorkstation" and "RDPNP" to always be in first and second place, this "NCFSD" and "Cwbnetnt" always has to be on the last 2 places and all the rest should be in the middle.

My question, how do I do that please, I've been battling for so Long already and I cant figure it out, I'm sorry, I know I'm a looser, but I try.

Any help would be appreciated

Thanks :-)

Share this post


Link to post
Share on other sites



new2daauto Please start a new topic and put a link to this one, this topic is +4 years old, a lot has changed in 4 years in AutoIt. And welcome to the forums :)

Share this post


Link to post
Share on other sites

new2daauto,

Palestinian is correct - I have created a new thread for you this time but please do not necro-hijack again. If required, the original thread is here. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Dear Palestinian and Melba23, thanks for the info and new post, I've never hear of necro-hijack but I wont do it again, sorry about that.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OK, this I have so far, and it works, sort of, only Problem I have is the Komma's :-( there is either too many of them or some are missing or not on the right place.

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs"
$sVal = RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder")
$sVal = StringRegExpReplace($sVal, "(?i)(.*)(NCFSD)(.*)", "$3$1,$2")
$sVal = StringRegExpReplace($sVal, "(?i)(.*),(Cwbnetnt)(.*)", "$3$1,$2")
$sVal = StringRegExpReplace($sVal, "(?i)(.*),(RDPNP)(.*)", "$2$1$3")
$sVal = StringRegExpReplace($sVal, "(?i)(.*),(LanmanWorkstation)(.*)", "$2,$1$3")
If @Extended Then RegWrite("HKLM64SYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder", "REG_SZ", $sVal)

The most important  is the first 2 and last 2, the rest inbetween is mostly unknown and therefor not possible to add them, but they have to stay in the string, they are not allowed to be removed.

I really hope someone can help me.

Edited by new2daauto

Share this post


Link to post
Share on other sites

Hi there,

Try to switch " to '

Just like this:

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs"
$sVal = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder")
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(NCFSD)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(Cwbnetnt)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(RDPNP)(.*)', '$2$1$3')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(LanmanWorkstation)(.*)', '$2,$1$3')
If @Extended Then RegWrite("HKLM64\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder", "REG_SZ", $sVal)

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi November, thank you very much for your help :-)

I tried your solution, but it still misses a "," between the 2 unknown names :-(

This is how I have it now (I replaced the registry string with my own value and added ConsoleWrite to test it without changing my Registry in real)

 

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs"
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)
;$sVal = RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder")
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(NCFSD)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(Cwbnetnt)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(RDPNP)(.*)', '$2$1$3')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(LanmanWorkstation)(.*)', '$2,$1$3')
;If @Extended Then RegWrite("HKLM64SYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder", "REG_SZ", $sVal)
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)

 

and this is the result;

LanmanWorkstation,RDPNP,vmhgfsNCFSD,webclient,Cwbnetnt

between "vmhgfs" and "NCFSD" there is the "," missing

Share this post


Link to post
Share on other sites

I heard that it is possible to use "Array" to split the "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs" into;

"NCFSD"

"RDPNP"

"webclient"

"Cwbnetnt"

"LanmanWorkstation"

"vmhgfs"

and then sort them so I have my 2 known names ("LanmanWorkstation" and "RDPNP")  in in first and second Position and ("NCFSD" and "Cwbnetnt") in second last and last Position and the unknown ones ("webclient" and "vmhgfs") in the middle like this;

"LanmanWorkstation"

"RDPNP"

"webclient"

"vmhgfs"

"NCFSD"

"Cwbnetnt"

and then rebuild it again to the string for the registry in the correct order like this;

"LanmanWorkstation,RDPNP,vmhgfs,NCFSD,webclient,Cwbnetnt"

and then RegWrite it back to the Registry.

 

Oh dear, I'm so sorry for being so complicated :-O I really hope I can be helped on this.

TIA

Share this post


Link to post
Share on other sites

Hi there,

I make it work in a lazy way:

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs,"
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)
;$sVal = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder")
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(NCFSD)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(Cwbnetnt)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(RDPNP)(.*)', '$2$1$3')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(LanmanWorkstation)(.*)', '$2,$1$3')
;If @Extended Then RegWrite("HKLM64\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder", "REG_SZ", $sVal)
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)

Just added a , in$vVal :)

Is that ok to you?

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hi again,

that is great, thanks, I'm also a bit lazy when battling for too Long, and your solution also works, Problem is that the "unknown values can be different and also more or less, if I Change the $sVal a bit and add some values and test it, we have the same Problem again with some "," being missing

$sVal = "onemore,vmhgfs,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,NCFSD,another"
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)
;$sVal = RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder")
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(NCFSD)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(Cwbnetnt)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(RDPNP)(.*)', '$2$1$3')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(LanmanWorkstation)(.*)', '$2,$1$3')
;If @Extended Then RegWrite("HKLM64SYSTEMCurrentControlSetControlNetworkProviderOrder", "ProviderOrder", "REG_SZ", $sVal)
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)

 

with this result

LanmanWorkstation,RDPNP,NCFSD,anotheronemore,vmhgfs,webclient,Cwbnetnt

between "another" and "onemore" the "," is missing :-(

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ok,

So let's get smart and lazy :)

$sVal = "onemore,NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs,another" & ","
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)
;$sVal = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder") & "," <== CHECK HERE!!!
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(NCFSD)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(Cwbnetnt)(.*)', '$3$1,$2')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(RDPNP)(.*)', '$2$1$3')
$sVal = StringRegExpReplace($sVal, '(?i)(.*),(LanmanWorkstation)(.*)', '$2,$1$3')
;If @Extended Then RegWrite("HKLM64\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder", "REG_SZ", $sVal)
ConsoleWrite($sVal)
ConsoleWrite(@CRLF)

Whatever would be there, just add an "," at the end and should be ok :)

Cheers

Edited by November

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

November, you are a lazy Genius :-) thank you so much :-)

now I only have 1 Problem, for some reason it doesn't put my "NCFSD" on the second to last Position :-( The one on the last and the 2 on first and second place works fine, just the second last one.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok ok,

Let get this as a semi-amateur :)

#include <array.au3>

Dim $newarray[0]

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs,old,new,medium"
ConsoleWrite("Initial : " & $sVal & @CRLF)
$array = StringSplit($sVal, ",")
_ArrayDelete($array, 0)
$limit = UBound($array)
$lan = _ArraySearch($array, "LanmanWorkstation")
$RDPNP = _ArraySearch($array, "RDPNP")
$NCFSD = _ArraySearch($array, "NCFSD")
$Cwbnetnt = _ArraySearch($array, "Cwbnetnt")
_ArrayDelete($array, $lan)
_ArrayDelete($array, $RDPNP)
_ArrayDelete($array, $NCFSD)
_ArrayDelete($array, $Cwbnetnt)
_ArrayAdd($newarray, "LanmanWorkstation")
_ArrayAdd($newarray, "RDPNP")
$limit = UBound($array)-1
for $x = 0 to $limit
    _ArrayAdd($newarray, $array[$x])
Next
_ArrayAdd($newarray, "NCFSD")
_ArrayAdd($newarray, "Cwbnetnt")
$sVal = _ArrayToString($newarray, ",")
ConsoleWrite("End : " & $sVal & @CRLF)

Maybe shorter and less confuse

#include <array.au3>

Dim $newarray[0]

$sVal = "NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs,old,new,medium"
;ConsoleWrite("Initial : " & $sVal & @CRLF) ; Just to check initial values
$array = StringSplit($sVal, ",")
_ArrayDelete($array, 0)
$limit = UBound($array)
_ArrayDelete($array, _ArraySearch($array, "LanmanWorkstation"))
_ArrayDelete($array, _ArraySearch($array, "RDPNP"))
_ArrayDelete($array, _ArraySearch($array, "NCFSD"))
_ArrayDelete($array, _ArraySearch($array, "Cwbnetnt"))
_ArrayAdd($newarray, "LanmanWorkstation")
_ArrayAdd($newarray, "RDPNP")
$limit = UBound($array) - 1
For $x = 0 To $limit
    _ArrayAdd($newarray, $array[$x])
Next
_ArrayAdd($newarray, "NCFSD")
_ArrayAdd($newarray, "Cwbnetnt")
$sVal = _ArrayToString($newarray, ",")
;ConsoleWrite("End : " & $sVal & @CRLF); Just to check final values

I hope it suites!

Cheers

Edited by November

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Wow November, that Looks really great :-) thank you very much :-)

 

When I try it, it Shows me this, I've got no idea what it means, I got lost after the Array_New.au3 already

Array_New.au3 (13) : ==> Array variable subscript badly formatted.:
Dim $newarray[0]
Dim $newarray[^ ERROR

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Which version of autoit are you running?

Did you included in your script?

Edited by November

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

SciTE Version 3.3.0

Include in my script? what script?

Share this post


Link to post
Share on other sites

OK, now I installed Version 3.3.12 and it is working, thank you very much for your help, I greatly appreciate it. I only have 1 post left till Today 06:32 PM and this is it, I dont know when I`ll be allowed to post again, so if I dont reply today, please know why.

Thanks a lot for your help November :-) you da best :-)

Share this post


Link to post
Share on other sites

Ok, 

I assumed that all regread would be the same, but maybe not :)

#include <array.au3>

Dim $newarray[0]

$sVal = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder");""NCFSD,RDPNP,webclient,Cwbnetnt,LanmanWorkstation,vmhgfs,old,new,medium"
ConsoleWrite("Initial : " & $sVal & @CRLF)
$array = StringSplit($sVal, ",")
_ArrayDelete($array, 0)
$limit = UBound($array)
$lan = _ArraySearch($array, "LanmanWorkstation")
if $lan >= 0 Then _ArrayDelete($array, $lan)
$RDPNP = _ArraySearch($array, "RDPNP")
if $RDPNP >= 0 Then _ArrayDelete($array,$RDPNP)
$NCFSD = _ArraySearch($array, "NCFSD")
if $NCFSD >= 0 Then _ArrayDelete($array,$NCFSD)
$Cwbnetnt = _ArraySearch($array, "Cwbnetnt")
if $Cwbnetnt >= 0 Then _ArrayDelete($array, $Cwbnetnt)
_ArrayAdd($newarray, "LanmanWorkstation")
_ArrayAdd($newarray, "RDPNP")
$limit = UBound($array)-1
for $x = 0 to $limit
    _ArrayAdd($newarray, $array[$x])
Next
_ArrayAdd($newarray, "NCFSD")
_ArrayAdd($newarray, "Cwbnetnt")
$sVal = _ArrayToString($newarray, ",")
ConsoleWrite("End : " & $sVal & @CRLF)

I think this will work!


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Once again, thank you for your help :-)

I tested this and there was a Little Problem, if one of the values does not exist in the Registry it gets added to the Registry, this is bad for the Network Settings :-O so I did the following, at least something I could do myself :-)

Here the complete Thing;

#include <array.au3>


Dim $newarray[0]

;$sVal = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder")
$sVal = "webclient,RDPNP,Cwbnetnt,LanmanWorkstation,vmhgfs,old,new,medium"
ConsoleWrite("Initial : " & $sVal & @CRLF)
$array = StringSplit($sVal, ",")
_ArrayDelete($array, 0)
$limit = UBound($array)
$lan = _ArraySearch($array, "LanmanWorkstation")
if $lan >= 0 Then _ArrayDelete($array, $lan)
$RDPNP = _ArraySearch($array, "RDPNP")
if $RDPNP >= 0 Then _ArrayDelete($array,$RDPNP)
$NCFSD = _ArraySearch($array, "NCFSD")
if $NCFSD >= 0 Then _ArrayDelete($array,$NCFSD)
$Cwbnetnt = _ArraySearch($array, "Cwbnetnt")
if $Cwbnetnt >= 0 Then _ArrayDelete($array, $Cwbnetnt)
if $lan >= 0 Then _ArrayAdd($newarray, "LanmanWorkstation")
if $RDPNP >= 0 Then _ArrayAdd($newarray, "RDPNP")
$limit = UBound($array)-1
for $x = 0 to $limit
    _ArrayAdd($newarray, $array[$x])
Next
if $NCFSD >= 0 Then _ArrayAdd($newarray, "NCFSD")
if $Cwbnetnt >= 0 Then _ArrayAdd($newarray, "Cwbnetnt")
$sVal = _ArrayToString($newarray, ",")
$sVal = _ArrayToString($newarray, ",")
;RegWrite("HKLM64\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order", "ProviderOrder", "REG_SZ", $sVal)
ConsoleWrite("End : " & $sVal & @CRLF)
Edited by new2daauto

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0