Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get item of a long registry value 1

Status
Not open for further replies.

dweeble

Technical User
Jan 3, 2006
6
Hi
I'm trying to pull just the "AMFALLNL002" from the default printer registry value located under here: "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
Value is "Device"="\\\http:\\server.one\\AMFALLNL002,winspool,Ne01:"
I can get the value into variable with "defPrntr = WshShell.RegRead(queName), but how can I get just the "AMFALLNL002" ?

Any help much appreciated,
Thanks
Michael
 
Split the variable on the \\ and use the last element of the array. Split that part using commas and use the first element of the new array.

Code:
DeviceStr="\\\http:\\server.one\\AMFALLNL002,winspool,Ne01:"

MyArray = Split(DeviceStr,"\\")

MySubArray = Split(MyArray(Ubound(MyArray)),",")

Wscript.Echo MySubArray(0)

I hope you find this post helpful.

Regards,

Mark
 
Hi Mark,
Hey Thanks much for your reply, this is what I did but not getting the result of (AMFALLNL002) in the variable "prtShare" ?
This is what's returned by printerPath,
\\ipp://metipp.aurora.org\AMFALLNL002,winspool,Ne05:


-----------------------------------------------------
Function GetDefaultPrinter ()
On Error Resume Next
Dim regKey, printerPath, Pcname, IcaWkst, qShare, Regcitrix
Dim IcaQue

regKey = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
printerPath = WshShell.RegRead(regKey)

Pcname = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
IcaWkst = WshShell.RegRead(Pcname)
IcaQue = printerPath
qShare = split(IcaQue,"\\")
prtShare = split(qShare(Ubound(qShare)),",")
WshShell.RegWrite(Regcitrix)&"ClientName" ,IcaWkst&"-"&prtShare WshShell.RegWrite(Regcitrix)&"ClientPrinter" , prtShare

If Err.Number = 0 And printerPath <> "" Then
 
Your starting values are differnet for the variable than you originally posted.

Change this
qShare = split(IcaQue,"\\")

To This
qShare = split(IcaQue,"\")

I hope you find this post helpful.

Regards,

Mark
 
Hi Mark,
Thanks for the reply.
I did try the option "/" but still did not get anything in the variable, but this below did the trick after some adjustments.

arrPrn = Split( strPrn, ",", -1, vbTextCompare )
strDescr = arrPrn(0)
arrPort = Split( arrPrn(2), ":", -1, vbTextCompare )
strPort = arrPort(0)

 
Yup, same basic principle. Glad you got it working.

I hope you find this post helpful.

Regards,

Mark
 
Mark
Thanks for your help and getting me on the trail.
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top