#90208 - 2002-12-05 09:04 PM
Re: remotely create mapped drive
|
Radimus
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.
|
Top
|
|
|
|
#90211 - 2002-12-06 03:13 PM
Re: remotely create mapped drive
|
Radimus
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.
|
Top
|
|
|
|
#90212 - 2002-12-06 03:55 PM
Re: remotely create mapped drive
|
Sealeopard
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
|
|
|
|
#90215 - 2002-12-06 04:06 PM
Re: remotely create mapped drive
|
Radimus
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
|
Top
|
|
|
|
#90217 - 2002-12-06 04:10 PM
Re: remotely create mapped drive
|
Radimus
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
|
Top
|
|
|
|
#90219 - 2002-12-06 04:17 PM
Re: remotely create mapped drive
|
Radimus
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
|
Top
|
|
|
|
#90221 - 2002-12-06 05:49 PM
Re: remotely create mapped drive
|
Radimus
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 ]
|
Top
|
|
|
|
#90223 - 2002-12-06 07:23 PM
Re: remotely create mapped drive
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
thanks
However, I will also need to check for persistence. [ 06. December 2002, 19:24: Message edited by: Radimus ]
|
Top
|
|
|
|
#90224 - 2002-12-06 08:22 PM
Re: remotely create mapped drive
|
Radimus
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
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|