#87677 - 2002-09-09 08:26 PM
remote environment paths
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
is there a COM or WMI method to get the path to the user's desktop/favorites remotely.
Basically I'm looking to push a file to the users desktop/favorites and readvalue returns info with environment variables
|
Top
|
|
|
|
#87678 - 2002-09-09 08:36 PM
Re: remote environment paths
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
this would work on the local machine, but I need remote paths
set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop")
|
Top
|
|
|
|
#87679 - 2002-09-09 08:41 PM
Re: remote environment paths
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You could fEnumKey() \\Computer\HKEY_USERS and ReadValue( "HKEY_USERS\$Sid\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Favorites") to get all users in an NT environment.
|
Top
|
|
|
|
#87680 - 2002-09-09 08:51 PM
Re: remote environment paths
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
but the problem is that some values return have %userprofile% or %windir% , etc in them...
this will get the user's folder, instead of the all users folders... which should be good enough I suppose...
$desktop =readvalue("\\$computer\$HKCUSMWCV\Explorer\Shell Folders","Desktop") [ 09. September 2002, 20:52: Message edited by: Radimus ]
|
Top
|
|
|
|
#87682 - 2002-09-09 09:14 PM
Re: remote environment paths
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The code below produces this output: quote: c:\data\scripts>%tmp%\kix32 junk.kix
.DEFAULT C:\WINDOWS\system32\config\systemprofile\Favorites S-1-5-19 C:\Documents and Settings\LocalService\Favorites S-1-5-19_Classes
S-1-5-20 C:\Documents and Settings\NetworkService\Favorites S-1-5-20_Classes
S-1-5-21-24129212-1035812195-1543859470-1416 C:\Documents and Settings\AdminHAB\Favorites S-1-5-21-24129212-1035812195-1543859470-1416_Classes
S-1-5-18 C:\WINDOWS\system32\config\systemprofile\Favorites c:\data\scripts>%tmp%\kix32 junk.kix
.DEFAULT C:\WINDOWS\system32\config\systemprofile\Favorites S-1-5-19 C:\Documents and Settings\LocalService\Favorites S-1-5-19_Classes
S-1-5-20 C:\Documents and Settings\NetworkService\Favorites S-1-5-20_Classes
S-1-5-21-24129212-1035812195-1543859470-1416 C:\Documents and Settings\AdminHAB\Favorites S-1-5-21-24129212-1035812195-1543859470-1416_Classes
S-1-5-18 C:\WINDOWS\system32\config\systemprofile\Favorites
This specific directory information is the same on NT, W2K, and a .NET Server. Not sure where you are getting the environment variables. As far as "All Users" goes take any of the paths above C:\Documents and Settings\NetworkService\Favorites\..\..\All Users\Favorites. Doesn't that work?code:
$Computer = "Bullockha2" $Keys = fEnumKey($Computer, "HKEY_USERS") for each $Sid in $Keys ? $Sid $Favorites =readvalue("\\$Computer\HKEY_USERS\$Sid\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Favorites") ? $Favorites
next
;FUNCTION fEnumKey($Computer, $Key) ; ;AUTHOR Howard A. Bullock (hbullock@comcast.net) ; ;ACTION Enumerates registries keys on the specified computer. ; ;SYNTAX fEnumKey($Computer, $Key) ; ;PARAMETERS $Computer (Required) - String value ; $Key (Required) - String value ; ;REMARKS Do not prefix the computer name with "\\"'s. Can serve as a ; direct replacement for EnumKey(). ; ;RETURNS Array of keys names. ; ;DEPENDENCIES KiXtart 4.02, ; ;EXAMPLES fEnumKey("", "HKEY_USERS") ; fEnumKey("Remote1", "HKEY_USERS") ; Function fEnumKey($Server, $Key) Dim $Index, $Error $Index = 0 Dim $KeyName[$Index] If $Server <> "" $Key = "\\" + $Server + "\" + $Key Endif
If KeyExist($Key) Do $x = ENUMKEY($Key, $Index) $Error = @Error If NOT $Error and $Index > Ubound($KeyName) ReDim PRESERVE $KeyName[$Index] Endif If NOT $Error $KeyName[$Index] = $x $Index = $Index + 1 Endif Until $Error Else $KeyName[0] = "" Exit 2 Endif $fEnumKey = $KeyName Exit 0 Endfunction
[ 09. September 2002, 21:17: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#87683 - 2002-09-10 03:10 PM
Re: remote environment paths
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
ok... When I do: $dest=readvalue("\\$computer\$HKCUSMWCV\Explorer\Shell Folders","Desktop")
it returns: c:\Documents and Settings\Default User\Desktop
apparently, I'm gonna have to parse Hkey_Users\
Is there an easy way determine the userid of the sid on a remote PC
|
Top
|
|
|
|
#87684 - 2002-09-10 03:13 PM
Re: remote environment paths
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
$acct = SidToName($key)
List accounts logged on to local or remote (NT, W2K, XP) computers
code:
For Each $key In fEnumKey($Computer, "HKEY_USERS") Dim $acct If Left($key,3) = "S-1" and Instr($key,"_") = 0 $acct = SidToName($key) If $acct = '' $acct = 'Sid from unknown SAM database.' Endif ? $key + " - " + $acct Endif Next
The down side here is that only active users are listed in HKEY_USERS. [ 10. September 2002, 15:23: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#87685 - 2002-09-10 07:57 PM
Re: remote environment paths
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
thanks... I did this.
code:
$index=0 :sidloop $sids=enumkey("\\$computer\hkey_users\",$index) if not @error and not instr($sids,"_") $sid=$sids $index=$index+1 goto sidloop endif $HKUsidSMWCV ="HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion"
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|