Page 2 of 2 <12
Topic Options
#90208 - 2002-12-05 09:04 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
This is turning out to be harder than I thought.

The basic idea is to be able to map a drive for a user without having to remote control it... but it is looking like this isn't gonna happen.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90209 - 2002-12-05 09:07 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It's definitely doable, however, the script must be execute under the user's account. Can't you just copy a link to his desktop and have him click it?
_________________________
There are two types of vessels, submarines and targets.

Top
#90210 - 2002-12-05 09:52 PM Re: remotely create mapped drive
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
doesn't the at service use current users rights when running in interactive mode?
_________________________
!

download KiXnet

Top
#90211 - 2002-12-06 03:13 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I think that either a desktop batch file or a regwrite to the runonce key is about the best that can be done.

anything too complex is more trouble than it worth... remote control would just be easier.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90212 - 2002-12-06 03:55 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Got a solution. And it's even very straight-forward and can be done with remote registry edit, too!
code:
[HKEY_CURRENT_USER\Network\O]
"RemotePath"="\\\\server\\share"
"UserName"=""
"ProviderName"="Microsoft Windows Network"
"ProviderType"=dword:00020000
"ConnectionType"=dword:00000001

I exported a example mapping from HKEY_CURRENT_USER, changed the drive letter in the registry key, used a different RemotePath, and reimported the .REG file back into the registry. After hitting 'Refresh' in the Explroer, i had the additional drive.

Give it a try, you should be able to write to \\COMPUTER\HKEY_CURRENT_USER, too.
_________________________
There are two types of vessels, submarines and targets.

Top
#90213 - 2002-12-06 04:02 PM Re: remotely create mapped drive
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Actually Jens, HKCU is not available remotely. You would have to go through HKEY_USERS\SID.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#90214 - 2002-12-06 04:04 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, that is true. I even do this in my own scripts whne writing to the registry. Should have been more precise with regards to the remote registry write.
_________________________
There are two types of vessels, submarines and targets.

Top
#90215 - 2002-12-06 04:06 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
that's OK.. I knew that.

but since it isn't CU, the user may not get it until logon
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90216 - 2002-12-06 04:08 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Confused]
I thought you want to remotely map a drive for a user that is already logged onto the computer?
_________________________
There are two types of vessels, submarines and targets.

Top
#90217 - 2002-12-06 04:10 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I do... but doesn't NT read user@sid at logon and place into hkcu. and logoff writes back to @sid

writing to @sid when the user is logged on, may not affect the current environment
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90218 - 2002-12-06 04:13 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I thought it's just a dynamic copy of HKEY_USERS\@SID and thus any change to that part will automatically affect the HKEY_CURRENT_USER setting.

Okay, I just tested this. I've made an registry entry in HKEY_USERS\@SID and then looked at HKEY_CURRENT_USER, and ..., the registry key was there!

[ 06. December 2002, 16:19: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#90219 - 2002-12-06 04:17 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
cool beans...

I have some reusable code to get the @sid of remote user.

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

Top
#90220 - 2002-12-06 04:42 PM Re: remotely create mapped drive
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well, if the user is not logged on then the hive would not be loaded... but then, the mapping could be put in their logon script anyway.

You could try GetSID(), my one and only contribution to the UDF lib.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#90221 - 2002-12-06 05:49 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
this makes a static mapping, I'll make a quickie popup to get the parameters later...

code:
Function MapDrive
$index=0
:sidloop
$sid=enumkey("\\$name\hkey_users\",$index)
if not @error and not instr($sids,"_")
$HKUsidSMWCVE = "HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Explorer"
$LogonName=readvalue("\\$name\$HKUsidSMWCVE","Logon User Name")
if not $remoteuser="@domain\$LogonName"
$index=$index+1
$sid=''
goto sidloop
endif
endif
if $sid
$letter="q"
$newpath="\\wheelerc\shared"
$=writevalue("\\$name\HKEY_USERS\$sid\Network\$letter","RemotePath","$newpath",REG_SZ)
$=writevalue("\\$name\HKEY_USERS\$sid\Network\$letter","UserName","",REG_SZ)
$=writevalue("\\$name\HKEY_USERS\$sid\Network\$letter","ProviderName","Microsoft Windows Network",REG_SZ)
$=writevalue("\\$name\HKEY_USERS\$sid\Network\$letter","ProviderType","131072",REG_Dword)
$=writevalue("\\$name\HKEY_USERS\$sid\Network\$letter","ConnectionType","00000001",REG_Dword)
endif
GetDrives()
endfunction

now, I'll write the inverse of this to delete a mapping...

[ 06. December 2002, 17:50: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90222 - 2002-12-06 05:51 PM Re: remotely create mapped drive
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just do a DELTREE for the drive letter that you want to delete.
_________________________
There are two types of vessels, submarines and targets.

Top
#90223 - 2002-12-06 07:23 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
thanks [Razz] [Roll Eyes]

However, I will also need to check for persistence.

[ 06. December 2002, 19:24: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90224 - 2002-12-06 08:22 PM Re: remotely create mapped drive
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
this is the function to get the sid of a remote user (assuming the user is logged in)
code:
 Function RemoteSid($computer, $remoteusername)
dim $sid, $logonname, $index, $HKUsidSMWCVE
$index=0
:sidloop
$sid=enumkey("\\$computer\hkey_users\",$index)
if not @error and not instr($sid,"_")
$HKUsidSMWCVE = "HKEY_USERS\$sid\Software\Microsoft\Windows\CurrentVersion\Explorer"
$LogonName=readvalue("\\$computer\$HKUsidSMWCVE","Logon User Name")
if $remoteusername=$LogonName
$RemoteSid=$sid
exit 0
return
else
$index=$index+1
$sid=''
exit 1
goto sidloop
endif
endif
endfunction

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

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.083 seconds in which 0.041 seconds were spent on a total of 13 queries. Zlib compression enabled.

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