Smaxey843's Profile
Reputation: 8
Worker
- Group:
- Active Members
- Active Posts:
- 74 (0.13 per day)
- Joined:
- 22-November 11
- Profile Views:
- 659
- Last Active:
Feb 05 2013 08:55 AM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Windows
- Favorite Browser:
- Chrome
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- PC
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: VBScript concatenation issue.
Posted 3 Feb 2013
Thank you Andrew. i'll plug that in when i have my test environment at work and report back.
THanks again.
Steven -
In Topic: Error : Type mismatch when referencing remote registry.
Posted 27 Aug 2012
Maj!
Thats awesome! In previous hack and slashes through unknown territory I had read that very post about profiles! Thank you for your patience and after rereading the thread I realized i never clearly declared what I was trying to accomplish.
I need to find out what the user path is for a user on a specified computer
the issue with this is that during a migration. half of the network ID's were one convention and the other half another. The folks in charge of the migration took the easy route and did not recreate profiles that comply with their naming convention. So we have usernames of jsmith and the path could be %systemdrive%\documents and settings\smithj OR e01234
So, the need to use the SID to determine a user's profile path on a remote computer was born. I got it to work, its an ugly little duck but it works to demonstrate the concept. whether or not to use this process will be decided beyond my pay grade. I need to get a rubber duck.
code below incase this helps someone in the future :
Option Explicit dim objWMIService, objRemoteWMIService, objWshNet, objFSO, objAccount, objShell, objReg, objSubkey dim strComputer, strRemoteComputer, strLIUser, strLIUserSID, strTargetuser, strLIDomain, strpartfilepath, strRegPartProfilePath, strRegProfilePath, strRegKeyPath, strValue, strRegKeyValueName, strRegSubKeyPath dim intTest dim arrSubkeys Const HKEY_LOCAL_MACHINE = &H80000002 'notify user that the script is executing Wscript.echo "Do not use this utility without the close attention of " & vbnewline &_ "the assistance of HUSA/SUSA Technical support staff" 'Step 1: Obtain currently logged on user's information. set objWshNet = WScript.CreateObject("WScript.Network") strLIUser = objWshNet.UserName strLIDomain = objWshNet.UserDomain strpartfilepath = "C:\documents and settings\" 'Step 2: Using information gathered in step one, determine the SID of the user strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objAccount = objWMIService.Get _ ("Win32_UserAccount.Name='" & strLIUser & "',Domain='" & strLIDomain & "'") strLIUserSID = objAccount.SID 'Test Echo to display logged on domain user's SID Wscript.Echo "on computer : " & strComputer &vbnewline & "User : " & strLIUser & vbnewline & " SID : "& strLIUserSID 'Step 3: Query the user for the address of the old computer's IP Address. StrRemoteComputer = inputbox("What is your old computer's IP Address?", "Old PC IP Address") 'Step 4: Connect to remote registry Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strRemoteComputer & "\root\default:StdRegProv") 'Initialize and define registry variables. strRegKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" strRegkeyValueName = "ProfileImagePath" strRegsubkeypath = strRegKeyPath & "\" & strLIUserSID 'Step 5: Querty remote registry for specified keys, collect keys into array, search array for the specific keypath including currently logged on user's SID to find the user's path on that machine. objreg.EnumKey HKEY_LOCAL_MACHINE,strRegKeyPath,ArrSubkeys objReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strRegsubKeyPath,strRegKeyValueName,strValue 'Test Echo 'wscript.echo " *** " &strRegSubKeypath &vbnewline & " *** " & strregkeyvaluename & vbnewline & " *** " & strValue 'Echo to report findings of this script. wscript.echo "in the case of "&strLIUser& " on " & strRemoteComputer & vbnewline &_ "The key path is : " & strRegKeyPath & vbnewline &_ "the key value name is : " & strRegKeyValueName & vbnewline &_ "the key value is : " & strValue wscript.echo "End of File" -
In Topic: Error : Type mismatch when referencing remote registry.
Posted 20 Aug 2012
Maj,
again thanks,
Option Explicit dim objWMIService, objRemoteWMIService, objWshNet, objFSO, objAccount, objShell, objReg dim strComputer, strRemoteComputer, strLIUser, strLIUserSID, strTargetuser, strLIDomain, strpartfilepath, strRegPartProfilePath, strRegProfilePath, strRegKeyPath, strValue, strRegKeyValueName dim intTest 'Step 1: set objWshNet = WScript.CreateObject("WScript.Network") strLIUser = objWshNet.UserName strLIDomain = objWshNet.UserDomain strpartfilepath = "C:\documents and settings\" strComputer = "." 'inputbox("What is the target computer's ip Address?") 'Wscript.echo strComputer Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objAccount = objWMIService.Get _ ("Win32_UserAccount.Name='" & strLIUser & "',Domain='" & strLIDomain & "'") strLIUserSID = objAccount.SID StrRemoteComputer = inputbox("What is your old computer's IP Address?", "Old PC IP Address") Set objRemoteWMIService = GetObject("winmgmts:\\" & strRemoteComputer & "\root\default:StdRegProv") 'Test Echo Wscript.Echo "on computer : " & strComputer &vbnewline & "User : " & strLIUser & vbnewline & " SID : "& strLIUserSID set objFSO = CreateObject("Scripting.FileSystemObject") Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strRemoteComputer & "\root\default:StdRegProv") strRegKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & strLIUserSID strRegkeyValueName = "ProfileImagePath" wscript.echo "reg read verification " & vbnewline & "HKEY_LOCAL_MACHINE" & vbnewline & _ "The key path is : " & strRegKeyPath & vbnewline &_ "the key value name is :" & strRegKeyValueName & vbnewline &_ "the key value is :" & strValue objReg.GetExpandedStringValue "HKEY_LOCAL_MACHINE",strRegKeyPath,strRegKeyValueName,strValue wscript.echo "in the case of "&strLIUser& " on " & strRemoteComputer & vbnewline &_ "The key path is : " & strRegKeyPath & vbnewline &_ "the key value name is :" & strRegKeyValueName & vbnewline &_ "the key value is :" & strValue 'WScript.Echo "Registry key path: " & strRegKeyPath & vbnewline & "Key Value: " &strRegProfilePath' check this against your profile lsit sid location and verify data wscript.echo "End of File"
The error has moved to line 36, which is
objReg.GetExpandedStringValue "HKEY_LOCAL_MACHINE",strRegKeyPath,strRegKeyValueName,strValue
the strValue is blank, the other data checks out as what I have intended.
I am a little baffled. I may be missing something that someone with formal training might know whats what. Thanks for looking through it again.
Steven -
In Topic: Error : Type mismatch when referencing remote registry.
Posted 20 Aug 2012
maj3091, on 18 August 2012 - 04:36 AM, said:Just to clarify, your error is with line 32 shown below as per the code tag lines?
32 wscript.echo "in the case of "&strLIUser& " on " & strRemoteComputer & vbnewline &_ "The key path is : " & strRegKeyPath & vbnewline &_ "the key value name is :" & strRegKeyValueName & vbnewline &_ "the key value is :" & strValue
If so, a couple of suggestions.
1. Declare your datatypes, at the moment, everything appears declared as a variant.
2. Try putting spaces between the ampersands and variables
Have you checked what variables are populated with using the immediate or locals window?
Maj, thanks for your reply.
I was incorrect, it is line 31 in which there is a type match failure.
Option Explicit dim objWMIService, objRemoteWMIService, objWshNet, objFSO, objAccount, objShell, objReg dim strComputer, strRemoteComputer, strLIUser, strLIUserSID, strTargetuser, strLIDomain, strpartfilepath, strRegPartProfilePath, strRegProfilePath, strRegKeyPath, strValue, strRegKeyValueName dim intTest 'Step 1: set objWshNet = WScript.CreateObject("WScript.Network") strLIUser = objWshNet.UserName strLIDomain = objWshNet.UserDomain strpartfilepath = "C:\documents and settings\" strComputer = "." 'inputbox("What is the target computer's ip Address?") 'Wscript.echo strComputer Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set objAccount = objWMIService.Get _ ("Win32_UserAccount.Name='" & strLIUser & "',Domain='" & strLIDomain & "'") strLIUserSID = objAccount.SID StrRemoteComputer = inputbox("What is your old computer's IP Address?", "Old PC IP Address") Set objRemoteWMIService = GetObject("winmgmts:\\" & strRemoteComputer & "\root\default:StdRegProv") 'Test Echo Wscript.Echo "on computer : " & strComputer &vbnewline & "User : " & strLIUser & vbnewline & " SID : "& strLIUserSID set objFSO = CreateObject("Scripting.FileSystemObject") Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strRemoteComputer & "\root\default:StdRegProv") strRegKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" & strLIUserSID strRegkeyValueName = "ProfileImagePath" objReg.GetExpandedStringValue "HKEY_LOCAL_MACHINE",strRegKeyPath,strRegKeyValueName,strValue wscript.echo "in the case of "&strLIUser& " on " & strRemoteComputer & vbnewline &_ "The key path is : " & strRegKeyPath & vbnewline &_ "the key value name is :" & strRegKeyValueName & vbnewline &_ "the key value is :" & strValue 'WScript.Echo "Registry key path: " & strRegKeyPath & vbnewline & "Key Value: " &strRegProfilePath' check this against your profile lsit sid location and verify data wscript.echo "End of File"
I will clean up the spacing and ampersands to make it a little more readable. I do not know how to check what a variable is populated with at a given time. I am currently coding using Notepad++ is there a more suitable tool for debugging VBScript?
Thanks again,
Steven -
In Topic: When did you decide to be a programmer?
Posted 1 May 2012
My Information
- Member Title:
- D.I.C Head
- Age:
- 27 years old
- Birthday:
- January 21, 1986
- Gender:
-
Contact Information
- E-mail:
- Click here to e-mail me
Friends
Smaxey843 hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
Smaxey843 has no profile comments yet. Why not say hello?