Page 1 of 1 1
Topic Options
#87677 - 2002-09-09 08:26 PM remote environment paths
Radimus Moderator Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87678 - 2002-09-09 08:36 PM Re: remote environment paths
Radimus Moderator Offline
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")
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87679 - 2002-09-09 08:41 PM Re: remote environment paths
Howard Bullock Offline
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87680 - 2002-09-09 08:51 PM Re: remote environment paths
Radimus Moderator Offline
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 ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87681 - 2002-09-09 09:12 PM Re: remote environment paths
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
I don't know what is the problem with the readvalue method as the environment vars are all in the registry...

[ 09. September 2002, 21:13: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#87682 - 2002-09-09 09:14 PM Re: remote environment paths
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87683 - 2002-09-10 03:10 PM Re: remote environment paths
Radimus Moderator Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87684 - 2002-09-10 03:13 PM Re: remote environment paths
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87685 - 2002-09-10 07:57 PM Re: remote environment paths
Radimus Moderator Offline
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"

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 373 anonymous users online.
Newest Members
Kelly001, MichaelK72, Janneman, standardbruker, maikoenig2001
17773 Registered Users

Generated in 0.045 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org