DeFuser Posted February 1, 2006 Posted February 1, 2006 Hello all,I am running into what I think (hope) is a small syntax issue, but it is driving me nuts regardless.I am trying to tweak the Windows registry to force all of our users into cached Exchange mode. The specific user name is part of the key snippet shown below:... \CurrentVersion\Windows Messaging Subsystem\Profiles\$username\13dbb0c8aa05101 ...I am using the RegWrite function. Unfortunately, I can not figure out how to incorporate the variable $username into the string required by RegWrite. Using MsgBox as an example (to keep things easy to read), I am trying to pull off the following:$age = "22"MsgBox(64,"FYI -", "You are " & $age "years old.", 5)"Your age in years is " & $age" is easy enough to do, but I have been nothing but (very) unsuccessful at putting the variable in the middle. I have tried various combinations of single quotes, double quotes, and ampersands to no avail.The fact that I haven't been able to find any documentation or examples of this leads me to think that I am barking up the wrong tree, but I don't have a clue as to the work-around. Then again I am surprised that nobody else has posted about this problem ... Hmm, maybe I'm just st00pid!Cheers and thanks,Def
Valuater Posted February 1, 2006 Posted February 1, 2006 (edited) maybe $age = "22" MsgBox(64,"FYI -", "You are " & $age & " years old.", 5) 8) Edited February 1, 2006 by Valuater
DeFuser Posted February 1, 2006 Author Posted February 1, 2006 MsgBox(64,"FYI -", "You are " & $age & " years old.", 5)Oh, how I wish it were that easy! Believe me, I really have tried to make this work - Including the double ampersand method you suggest. Mind you that I have been mucking with the RegWrite command, but I figured that the solution would be the same for RegWrite and MsgBox and used the MsgBox example for clarity. My actual (and quite ugly) line is:RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\username\13dbb0c8aa05101a9bb000aa002fc45a", "00036601", "REG_BINARY", "04000000")I appreciate the quick response though!Cheers,Def
Valuater Posted February 1, 2006 Posted February 1, 2006 $username = @UserName ;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\username\13dbb0c8aa05101a9bb000aa002fc45a", "00036601", "REG_BINARY", "04000000") MsgBox(64, "Test", "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & $username &"\13dbb0c8aa05101a9bb000aa002fc45a") 8)
SlimJim Posted February 2, 2006 Posted February 2, 2006 I believe you need to use Opt("ExpandVarStrings",1) which allows you to use variables inside strings. I have not used this myself but it is mentioned in the help file with the example of a string "The value of var1 is $var1$"
w0uter Posted February 2, 2006 Posted February 2, 2006 Valuater's way is better My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
MuffinMan Posted February 2, 2006 Posted February 2, 2006 (edited) Defuser, I am a total noob, but I got very confused by these middle variable things today and here's what I came up with to help clear things up for me - maybe it will help you - it will most likely scare the rest of you Of course, the code assumes that $user is your username variable, and I remarked out the RegWrite line, but I left the message box so you could see the output. $Beg = """HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" $mid = $user $End = "\13dbb0c8aa05101a9bb000aa002fc45a"" " MsgBox(0, "Test", $Beg & $Mid & $End) ;RegWrite($Beg & $Mid & $End, "00036601", "REG_BINARY", "04000000") Edited February 2, 2006 by MuffinMan
DeFuser Posted February 2, 2006 Author Posted February 2, 2006 Valuater. your solution did indeed work. Matter of fact, it worked in both instances. I used the trusty copy-n-paste on your first example and (quite to my astonishment) it worked perfectly. I then manually entered the RegWrite line (paying close attention to entering the problem section exactly as you presented it)xs and it worked the very first time - without a hitch - right out of the box even! I have yet to figure out what I was doing wrong, but I have a suspicion that the compiler is more sensitive to spaces than I thought it was. The good news is that I now know that it can be done and I also know how to do it.So once again, I'd like to thank you - Twice even. And by all means feel free to enjoy knowing that you solved in a few minutes what frustrated me for a few hours. Best wishes,A very happy DefSlimJim - Thanks for your input too
Valuater Posted February 2, 2006 Posted February 2, 2006 Valuater. your solution did indeed work. Matter of fact, it worked in both instances. I used the trusty copy-n-paste on your first example and (quite to my astonishment) it worked perfectly. I then manually entered the RegWrite line (paying close attention to entering the problem section exactly as you presented it)xs and it worked the very first time - without a hitch - right out of the box even! I have yet to figure out what I was doing wrong, but I have a suspicion that the compiler is more sensitive to spaces than I thought it was. The good news is that I now know that it can be done and I also know how to do it.So once again, I'd like to thank you - Twice even. And by all means feel free to enjoy knowing that you solved in a few minutes what frustrated me for a few hours. Best wishes,A very happy DefSlimJim - Thanks for your input too That was really nice, most people don't even say "thanks"....comments like that make all of the Helping people here at AutoIt, like myself, Want to help others8)
greenmachine Posted February 2, 2006 Posted February 2, 2006 Valuater. your solution did indeed work. Matter of fact, it worked in both instances. I used the trusty copy-n-paste on your first example and (quite to my astonishment) it worked perfectly. I then manually entered the RegWrite line (paying close attention to entering the problem section exactly as you presented it)xs and it worked the very first time - without a hitch - right out of the box even! I have yet to figure out what I was doing wrong, but I have a suspicion that the compiler is more sensitive to spaces than I thought it was. The good news is that I now know that it can be done and I also know how to do it. So once again, I'd like to thank you - Twice even. And by all means feel free to enjoy knowing that you solved in a few minutes what frustrated me for a few hours. Best wishes, A very happy Def SlimJim - Thanks for your input too [ old code] $age = "22" MsgBox(64,"FYI -", "You are " & $age "years old.", 5) [ /old code] I think your problem all along was simply that you forgot the other & after the $age. Honestly, I think that was the only problem (you did mention that you tried that method already, so I'm not sure how that didn't work). @MuffinMan: $Beg = """HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" $mid = $user $End = "\13dbb0c8aa05101a9bb000aa002fc45a"" " MsgBox(0, "Test", $Beg & $Mid & $End) ;RegWrite($Beg & $Mid & $End, "00036601", "REG_BINARY", "04000000") It would probably be easier for you to use both single and double quotations when you need to enclose the string in quotes. In other words, ' " ' instead of " " " (both do the same thing, one is just a little easier to read in my opinion).
MuffinMan Posted February 2, 2006 Posted February 2, 2006 Thanks greenmachine I didn't know about the single quotes - that makes things a lot less confusing!
DeFuser Posted February 2, 2006 Author Posted February 2, 2006 I think your problem all along was simply that you forgot the other & after the $age. Honestly, I think that was the only problem (you did mention that you tried that method already, so I'm not sure how that didn't work).Hey all, I really want to say thanks for all of the input and assistance. I was digging through one of my testing phase .au3 files and found the following:... Subsystem\Profiles\" & $username &"\13dbb0c8aa05101a9bb...I am thinking that it wasn't the second ampersand that got me; it was the spaces. Methinks that I was thinking of the "&" as continuation character. I probably tried (along with various combinations and omissions of single and double quotes):" & $username &"" &$username& ""& $username &""& $username & "And to think that I was so close! I kid you not, I toyed with this (and with potential work-arounds) for hours. I actually had myself thinking that "there must be some other command for instances like this." The bright side is that hopefully you guys who are familiar with this stuff will at least get a chuckle out of it.Hey, how do I make a contribution to the .chm file? Cheers,Def
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now