The brackets just tell action script to interpret whatever is in them as relevance. Since you already have the expression in brackets, adding “{parameter “_FindServer” of action }” is equivalent to putting brackets into QNA, which is an illegal character.
replace those brackets with parentheses and you should be fine
Since you can’t guarentee that the user of your fixlet will always type in lowercase, you might want to lowercase the parameter.
I didn’t test this (I’m at home), but maybe something like:
appendfile {("%22" & name of it & “%22=%22” & escape of ("\SOMETHINGELSE" & following text of position 13 of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with (parameter “_FindServer” of action as lowercase)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
appendfile {("%22" & name of it & “%22=%22” & escape of ("\SOMETHINGELSE" & following text of position 13 of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with
parameter “_FindServer” of action
) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
It didn’t work when I tried to add another:
appendfile {("%22" & name of it & “%22=%22” & escape of ("\SOMETHINGELSE" & following text of position
parameter “_NumberofCharacters” of action
of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with parameter “_FindServer” of action) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
I’d suspect your parameter is being treated as a string.
Try this:
appendfile {("%22" & name of it & “%22=%22” & escape of ("\SOMETHINGELSE" & following text of position (parameter “_NumberofCharacters” of action as integer) of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with parameter “_FindServer” of action) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
For what it’s worth, depending on how you’re using the fixlet will denote the best approach to writing the whole relevence. In the sample I started you with, it was assumed that we’re manipulating environment variables that contain a UNC where you need to replace the server with another. So I’m assuming it must be “\” + oldserver + “”.
I wouldn’t bother with your second parameter at all. The second parameter is simply the length of the old server name + 3.
So skip _NumberofCharacters and change it to be…
appendfile {("%22" & name of it & “%22=%22” & escape of ("\SOMETHINGELSE" & following text of position
(3+length of parameter “_FindServer” of action)
of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with (parameter “_FindServer” of action
as lowercase
)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
ps. I added the additional “as lowercase”. See the bolded areas.
appendfile {("%22" & name of it & “%22=%22” & escape of (parameter “_ReplaceServer” of action & following text of position (3+length of parameter
“_ReplaceServer”
of action) of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with (parameter “_FindServer” of action as lowercase)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
I had to change the bolded parameter to the REPLACE server and not the find server… Have an issue still, however…
The action is putting another set of “\” and I’m not sure why…
Also, to make this easier for user input… It will also be a UNC so it would be nice if I didn’t have to enter the \ before the server name and the \ after (ie: \SERVERNAME\ ) and instead would be nice to just enter the server name for both the find and replace values.
No, it’s 3+length of _FindServer. In the registry it’s currently like “\findserver\whatever”. We’re trying to take everything after “\findserver” which is simply “whatever”. So you need to take everything after position 13 in this case. If it was “\old\whatever” in the registry, then we want to take everything after position 6.
To not have to type in the backslashes, just add it to the action…
appendfile {("%22" & name of it & “%22=%22” & escape of ("\" & parameter “_ReplaceServer” of action & “” & following text of position (3+length of parameter “_FindServer” of action) of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with (parameter “_FindServer” of action as lowercase)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry}
One last thing is the “FindServer” I still have to type in the \SERVERNAME\ instead of SERVERNAME… When I type in just servername it doesn’t find anything but when I type in \servername\ it does.
("%22" & name of it & “%22=%22” & escape of ("\" & parameter “_ReplaceServer” of action & “” & following text of position (3+length of parameter “_FindServer” of action) of it & “%22%0d%0a”) of (it as string)) of values whose (it as string as lowercase starts with ("\" & parameter “_FindServer” of action as lowercase & “”)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry
Try creating a value in the registry with a ", then export that to a .reg. You’ll see it’s in there as "
So that makes sense.
Like this:
escape of “%22”
Try this. I put the “%22%0d%0a” outside of the “escape of”:
("%22" & name of it & “%22=%22” & escape of ("\" & parameter “_ReplaceServer” of action & “” & following text of position (3+length of parameter “_FindServer” of action) of it) of (it as string) & “%22%0d%0a”) of values whose (it as string as lowercase starts with ("\" & parameter “_FindServer” of action as lowercase & “”)) of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry
If you have a known number of server names that need to be replaced, you should look for those specific server names in the relevance. In doing that, you can probably eliminate the whole parameter thing since you know that the PCs must have at least 1 of the targeted server names to replace. But that would change your action around again. This is why it’s good to define your relevence properly so you don’t keep rewriting your actions.
Sorry to bump again… This should be easy for you Paul but not so much for me… You helped me find and replace variables… Now I simply want to be able to create a NEW one with the action parameters…
IE:
Action Parameter: Variable Name (SAMPLE_NAME)
Action Parameter: Variable Value (\SERVERNAME\SHARENAME)
action parameter query “_VariableName” with description “Please enter the variable NAME:” with default value “HOME-FS”
action parameter query “_VariableValue” with description “Please enter the variable VALUE. NOTE THE DOUBLE SLASH AFTER THE SERVER NAME:” with default value “\SERVERNAME\CBSAPPS”
Yep, that will work. But maybe you want to look at “escape of” so the console user can enter it as \server\service without having to remember the extra slashes.