Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


First Name Registry entry

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,52819
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> First Name Registry entry
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 First Name Registry entry - 10/18/2007 7:15:59 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
How can I get this to work, problem is in the regwrite area, maybe there is another way to pass the & objUser.Get("givenName") to the regwrite statement


      
 
 
Post #: 1
 
 RE: First Name Registry entry - 10/18/2007 9:18:30 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
WshShell.Regwrite "HKCU\Software\Visioneer\PaperPort\ScanWatch\Folder", "\\\\server\\scans\\cw_scan\\data\\users\\" & objUser.Get("givenName")", "REG_SZ"

You don't need those quotation marks after the objUser.Get("givenName")

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to gdewrance)
 
 
Post #: 2
 
 RE: First Name Registry entry - 10/18/2007 9:26:30 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
Thanks that fixed it 

(in reply to ginolard)
 
 
Post #: 3
 
 RE: First Name Registry entry - 10/18/2007 9:56:04 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
I have one other problem, how can I pull only the first 8 letters of the givenname

(in reply to gdewrance)
 
 
Post #: 4
 
 RE: First Name Registry entry - 10/18/2007 9:58:17 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Look at the Left() function.

(in reply to gdewrance)
 
 
Post #: 5
 
 RE: First Name Registry entry - 10/18/2007 10:13:42 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
Thanks ehvbs, where am I going wrong here.
UserFirstName echo's out the correct name 3 characters long, but still adds the full givenName to the registry.

'On Error resume next
Set WshShell = CreateObject("Wscript.Shell")
Set objRootDSE = GetObject("LDAP://RootDSE")

If Err.Number = 0 Then
   strNamingContext = objRootDSE.Get("defaultNamingContext")
End If

Set objADSysInfo = CreateObject("ADSystemInfo")
strUserDN = objADSysInfo.username

' Bind to user object
Set objUser = Getobject("LDAP://" & strUserDN)
WScript.Echo "First name:........ " & objUser.Get("givenName")

UsersFirstName = objUser.Get("givenName")
wscript.echo (Left(UsersFirstName,3))

WshShell.Regwrite "HKCU\Software\Visioneer\PaperPort\ScanWatch\Folder", "\\server1\scans\cw_scan\data\users\" & UsersFirstName, "REG_SZ"
WshShell.Regwrite "HKEY_USERS\S-1-5-21-1644491937-261478967-1801674531-1108\Software\Visioneer\PaperPort\ScanWatch\Folder", "\\server1\scans\cw_scan\data\users\" & UsersFirstName, "REG_SZ"

(in reply to ehvbs)
 
 
Post #: 6
 
 RE: First Name Registry entry - 10/18/2007 10:27:40 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
blond moment for someone who's not blond, that was a really stupid question.
I fixed it

(in reply to gdewrance)
 
 
Post #: 7
 
 RE: First Name Registry entry - 10/18/2007 10:29:56 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
UsersFirstName = objUser.Get("givenName")
wscript.echo (Left(UsersFirstName,3))  ' <--- doesn't change UsersFirstName

==>

UsersFirstName = objUser.Get("givenName")
wscript.echo UsersFirstName
UsersFirstName = Left( UsersFirstName,3 )
wscript.echo UsersFirstName

(in reply to gdewrance)
 
 
Post #: 8
 
 RE: First Name Registry entry - 10/18/2007 11:26:39 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
Yip saw that thanks,
by the way is it good scripting to assign UserFirstName two values?

UsersFirstName = objUser.Get("givenName")

UsersFirstName = Left( UsersFirstName,3 )

I done mine like this

UsersFirstName = objUser.Get("givenName")
enterName = (Left(UsersFirstName,8))

(in reply to ehvbs)
 
 
Post #: 9
 
 RE: First Name Registry entry - 10/19/2007 12:03:02 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
In general, one variable should hold one 'thingy' (value/info). But what exactly is
one thingy? It depends on what you are doing. Given that a user has a first name
(Robert) and a login name (Rob) that is used as a folder name, then there already
three thingies. If your script displays the first name and stores the folder name,
then having two variables (sUsersFirstName, sUsersFolderName) is reasonable.

sUsersFirstName = objUser.Get( "givenName" )
sUsersFolderName = Left( sUsersFirstName, 3 )
...
WScript.Echo "storing folder name", sUsersFolderName, "for user", sUsersFirstName

Sometimes you aren't really interested in showing the steps used to create/compute a single
thingy, but would like to document the steps in the code - instead of writing a complicated
expression:

  nPrice = (getSinglePrice( "widget" ) * nCount) + ((getSinglePrice( "widget" ) * nCount) * 0.10) ... add tax

a step by step approach

  nPrice = getSinglePrice( "widget" )
  nPrice = nPrice + nPrice * 0.10
  nPrice = nPrice * 1.17

(or something that would be accepted by an accountant) makes sense.

(in reply to gdewrance)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> First Name Registry entry Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts