Yeah, I know about the msgbox, I just don't have any care about that. I'm only displaying the information to verify it is pulling the corrent information. Remember, this is only the first half of the first of 3 steps in the ultimate goal of this script. As for the Dims, call it habit.
What I enter into the prompt for a machine name is the machine name. Remember, I'm running XP and am trying to pull the information for a 7 machine. Locally, using ".", "127.0.0.1", "localhost", my machine name, or my IP address all return the correct values. I actually hadn't tried running it directly for a 7 machine. ^^'
Alright, so that changes the problem a bit. I'll try to make this into a table to make it a little easier to understand.
Code:
Ran To
---------------
Ran From | . | XP | 7 |
---------|---|----|----|
XP | G | G | E1 |
---------|---|----|----|
7 | G | E2 | E1 |
------------------------
G = Good
E1 = Error: Not found; Code: 80041002; Source: SWbemServicesEx
E2 = SID is Null
It's kinda hard to test something out when you only have one or two machines and they don't have the right OS' to manipulate them in, but I appreciate all your help in trying. I just wish I could be a little more help on it all. ^^'
Edit:
As a means to try to get several perspectives and hoping find a solution sooner, I posted on TechNet:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/ad0262e0-4ad9-452a-baf4-0904da09c288
Don't get me wrong, I know these guys are smart and good, but this guy has to be joking to tell me that the code I provided won't run remotely at all. XD
Edit:
I'm a bit in shock after the whole "the provided script can't run remotely" thing, but TechNet gave me the answer, sorta. Maybe they did and I just ain't connecting all the dots of what they said.
Anyways, I've been trying to have the remote computer run the pull of the SID, but it's a network-based account system, making the SID universal across the entire network! I simply modified the SID search to run locally, instead of remotely, and it now work in all senarios from Win XP and Win 7! To make it better, since it's a universal command, I don't have to seperate it, making less code!
Code:
Option Explicit
Dim strComputer
Dim objWMI
Dim colItems
Dim objItem
Dim VerBig
Dim OSystem
Dim WSHShell
Dim colItems2
Dim objItem2
Dim arrName
Dim domain
Dim currentUser
Dim colItems3
Dim objItem3
Dim SID
Dim objAccount
Dim storeToPath
' Here is where we interrogate the Operating System
' On Error Resume Next
' Get the computer name (ie . = localhost)
strComputer = InputBox("Computer Name or IP Address: ")
' Remote connection path
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
' This is where WMI interrogates the operating system
Set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)
' Here we filter Version from the dozens of properties
For Each objItem in colItems
VerBig = Left(objItem.Version,3)
Next
' Spot VerBig variable in previous section
' Note the output variable is called OSystem
' This is where WMI interrogates the computer system
Set colItems2 = objWMI.ExecQuery("Select * from Win32_ComputerSystem",,48)
Select Case VerBig
Case "6.1"
OSystem = "7"
Set WSHShell = CreateObject("WScript.Shell")
domain = WshShell.ExpandEnvironmentStrings("%userdomain%")
currentUser = WshShell.ExpandEnvironmentStrings("%username%")
Case "5.1"
OSystem = "XP"
' Here we filter UserName from the dozens of properties
For Each objItem2 in colItems2
arrName = Split(objItem2.UserName, "\")
domain = arrName(0)
currentUser = arrName(1)
Next
Case Else OSystem = "Invalid OS"
End Select
' This is where WMI interrogates the user account
Set objAccount = GetObject("winmgmts:root/cimv2:Win32_UserAccount.Domain='" & domain & "'" & ",Name='" & currentUser & "'")
SID = objAccount.SID
' Spot VerBig variable in previous section
' Note the output variable is called storeToPath
Select Case VerBig
Case "6.1"
storeToPath = "C:\Users\" & currentUser
Case "5.1"
storeToPath = "D:\Documents and Settings\" & currentUser
End Select
Wscript.Echo "Version No: " & VerBig & vbCr _
& "OS System: " & OSystem & vbCr _
& "Save to Path: " & storeToPath & vbCr _
& "User SID: " & SID
WScript.Quit
' End of script
Now I just need to make the regedits to back-up the information, incorporate PST mappings, a pause while the user logs off, the renaming of the profile remotely(, removal of registry entry in Win 7), another pause while the user logs in and the profile is rebuilt, copy files from the old profile to the new, and restore all those backed up mappings. Joy!