Mapping drive to user's home directory
Author |
Message |
Brad Elliot #1 / 8
|
 Mapping drive to user's home directory
Is there a way to reference a user's home directory in a WSH script? I'm trying to make a WSH script to replace our BAT login script - but while in the BAT file I can map a drive to the user's home directory by using NET USE H: /HOME, the WSH script does not seem to let me use the HOME variable (it fails to map that drive). Does anybody know to accomplish this? BTW, this is for an NT4 domain - not AD. Thanks.
|
Mon, 16 Aug 2004 23:08:10 GMT |
|
 |
KeVi #2 / 8
|
 Mapping drive to user's home directory
Quote:
> Is there a way to reference a user's home directory in a WSH script? > I'm trying to make a WSH script to replace our BAT login script - but while > in the BAT file I can map a drive to the user's home directory by using NET > USE H: /HOME, the WSH script does not seem to let me use the HOME variable > (it fails to map that drive). > Does anybody know to accomplish this? > BTW, this is for an NT4 domain - not AD. > Thanks.
try set wshell=createobject("wscript.shell") wshell.run("cmd /c net use H: /home") I know there was a way to get environmental variables, but I dont recall how. The above will work, however
|
Tue, 17 Aug 2004 02:38:19 GMT |
|
 |
Alex Angelopoulo #3 / 8
|
 Mapping drive to user's home directory
Brad, what is the actual code you were using? The "/HOME" is a switch, not a variable, and should work fine in a logon script from WSH. Assuming you are using Win9x clients, there is another issue which can occur, where the first attempt to make use of the user name information from the WSH Network object fails. Although you are not explicitly doing that, it is possible that the same issue is presenting you with a problem. There are a couple of tricks that can allow you to work around that problem (involving suppressing errors, trying to get the user name, then sleeping for a few hundred milliseconds and trying again). If you post what you have and what errors it gives you, it may be possible to identify the issue and resolve it so you don't have to abandon your planned approach.
: Is there a way to reference a user's home directory in a WSH script? : : I'm trying to make a WSH script to replace our BAT login script - but while : in the BAT file I can map a drive to the user's home directory by using NET : USE H: /HOME, the WSH script does not seem to let me use the HOME variable : (it fails to map that drive). : : Does anybody know to accomplish this? : : BTW, this is for an NT4 domain - not AD. : : Thanks. : :
|
Tue, 17 Aug 2004 03:13:42 GMT |
|
 |
Brad Elliot #4 / 8
|
 Mapping drive to user's home directory
The actual code I was trying is: Dim WshNetwork Set WshNetwork = CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "H:", Home I also tried using /Home, "Home" (with the quotes), and "/Home" - any variation I could think of for the switch that works in batch files. The error I get is either 'the network name cannot be found' or 'the network name does not exist' - depending on which syntax I try. Incidentally, I'm running this on a Win2K box, but I get the same thing on NT4. I'm aware of the Win9x problem & the need to compensate by going to sleep for a second or two, but that's not really applicable here. Thanks for your response, Brad
Quote: > Brad, > what is the actual code you were using? > The "/HOME" is a switch, not a variable, and should work fine in a logon
script from WSH. Assuming you are using Win9x clients, Quote: > there is another issue which can occur, where the first attempt to make
use of the user name information from the WSH Network object Quote: > fails. Although you are not explicitly doing that, it is possible that
the same issue is presenting you with a problem. There are Quote: > a couple of tricks that can allow you to work around that problem
(involving suppressing errors, trying to get the user name, then Quote: > sleeping for a few hundred milliseconds and trying again). > If you post what you have and what errors it gives you, it may be possible
to identify the issue and resolve it so you don't have to Quote: > abandon your planned approach.
Quote: > : Is there a way to reference a user's home directory in a WSH script? > : > : I'm trying to make a WSH script to replace our BAT login script - but while > : in the BAT file I can map a drive to the user's home directory by using NET > : USE H: /HOME, the WSH script does not seem to let me use the HOME variable > : (it fails to map that drive). > : > : Does anybody know to accomplish this? > : > : BTW, this is for an NT4 domain - not AD. > : > : Thanks. > : > :
|
Tue, 17 Aug 2004 23:23:51 GMT |
|
 |
Alex Angelopoulo #5 / 8
|
 Mapping drive to user's home directory
I see... "/home" is _only_ a switch for "net use". It _is_ available if you are spawning out to a command prompt and running something like: set oShell = CreateObject("Wscript.Shell") oShell.Run "%COMSPEC% /C net use H: /home" Which is what I thought you were doing. In either case, it turns out that this should be redundant in your case. If a user is logging on to a domain from an NT4 or Win2K system and has a valid drive letter and path set up in the domain User account for their "home", the drive mapping should occur automatically. If you are not getting the drive mapping to occur automatically, there may be another issue. Try explicitly mapping the drive from a command prompt and see whether it maps; if not, what error do you get?
: The actual code I was trying is: : : Dim WshNetwork : Set WshNetwork = CreateObject("WScript.Network") : WshNetwork.MapNetworkDrive "H:", Home : : I also tried using /Home, "Home" (with the quotes), and "/Home" - any : variation I could think of for the switch that works in batch files. : : The error I get is either 'the network name cannot be found' or 'the network : name does not exist' - depending on which syntax I try. : : Incidentally, I'm running this on a Win2K box, but I get the same thing on : NT4. I'm aware of the Win9x problem & the need to compensate by going to : sleep for a second or two, but that's not really applicable here. : : Thanks for your response, : : Brad :
: > Brad, : > : > what is the actual code you were using? : > : > The "/HOME" is a switch, not a variable, and should work fine in a logon : script from WSH. Assuming you are using Win9x clients, : > there is another issue which can occur, where the first attempt to make : use of the user name information from the WSH Network object : > fails. Although you are not explicitly doing that, it is possible that : the same issue is presenting you with a problem. There are : > a couple of tricks that can allow you to work around that problem : (involving suppressing errors, trying to get the user name, then : > sleeping for a few hundred milliseconds and trying again). : > : > If you post what you have and what errors it gives you, it may be possible : to identify the issue and resolve it so you don't have to : > abandon your planned approach. : >
: > : Is there a way to reference a user's home directory in a WSH script? : > : : > : I'm trying to make a WSH script to replace our BAT login script - but : while : > : in the BAT file I can map a drive to the user's home directory by using : NET : > : USE H: /HOME, the WSH script does not seem to let me use the HOME : variable : > : (it fails to map that drive). : > : : > : Does anybody know to accomplish this? : > : : > : BTW, this is for an NT4 domain - not AD. : > : : > : Thanks. : > : : > : : > : > : :
|
Tue, 17 Aug 2004 23:53:40 GMT |
|
 |
Richard Muelle #6 / 8
|
 Mapping drive to user's home directory
In Active Directory: Set oNet = CreateObject("Wscript.Network") Set oUser = GetObject("WinNT://MyDomain/j_user,user") sHomeShare = oUser.HomeDirectory sHomeDrive = oUser.HomeDirDrive oNet.MapNetworkDrive sHomeDrive, sHomeShare Could this work in an NT domain? If not, you're stuck with net use. Also, I find that home drive is only mapped automatically on W2k clients (unless you use persistent connections). Richard Quote: >-----Original Message----- >I see... >"/home" is _only_ a switch for "net use". It _is_
available if you are spawning out to a command prompt and running something like: Quote: >set oShell = CreateObject("Wscript.Shell") >oShell.Run "%COMSPEC% /C net use H: /home" >Which is what I thought you were doing. >In either case, it turns out that this should be
redundant in your case. If a user is logging on to a domain from an NT4 or Win2K Quote: >system and has a valid drive letter and path set up in
the domain User account for their "home", the drive mapping should occur Quote: >automatically. >If you are not getting the drive mapping to occur
automatically, there may be another issue. Try explicitly mapping the drive from Quote: >a command prompt and see whether it maps; if not, what error do you get?
Quote: >: The actual code I was trying is: >: >: Dim WshNetwork >: Set WshNetwork = CreateObject("WScript.Network") >: WshNetwork.MapNetworkDrive "H:", Home >: >: I also tried using /Home, "Home" (with the quotes), and "/Home" - any >: variation I could think of for the switch that works in batch files. >: >: The error I get is either 'the network name cannot be
found' or 'the network Quote: >: name does not exist' - depending on which syntax I try. >: >: Incidentally, I'm running this on a Win2K box, but I
get the same thing on Quote: >: NT4. I'm aware of the Win9x problem & the need to
compensate by going to Quote: >: sleep for a second or two, but that's not really applicable here. >: >: Thanks for your response, >: >: Brad >:
without _ _> wrote in Quote:
>: > Brad, >: > >: > what is the actual code you were using? >: > >: > The "/HOME" is a switch, not a variable, and should
work fine in a logon Quote: >: script from WSH. Assuming you are using Win9x clients, >: > there is another issue which can occur, where the
first attempt to make Quote: >: use of the user name information from the WSH Network object >: > fails. Although you are not explicitly doing that, it is possible that >: the same issue is presenting you with a problem. There are >: > a couple of tricks that can allow you to work around that problem >: (involving suppressing errors, trying to get the user name, then >: > sleeping for a few hundred milliseconds and trying again). >: > >: > If you post what you have and what errors it gives
you, it may be possible Quote: >: to identify the issue and resolve it so you don't have to >: > abandon your planned approach. >: >
in message
>: > : Is there a way to reference a user's home directory in a WSH script? >: > : >: > : I'm trying to make a WSH script to replace our BAT login script - but >: while >: > : in the BAT file I can map a drive to the user's
home directory by using Quote: >: NET >: > : USE H: /HOME, the WSH script does not seem to let me use the HOME >: variable >: > : (it fails to map that drive). >: > : >: > : Does anybody know to accomplish this? >: > : >: > : BTW, this is for an NT4 domain - not AD. >: > : >: > : Thanks. >: > : >: > : >: > >: > >: >: >.
|
Wed, 18 Aug 2004 03:38:13 GMT |
|
 |
Alex Angelopoulo #7 / 8
|
 Mapping drive to user's home directory
Maybe I'm seeing a server-side thing then - I have an NT 4 client system logging in to a win2K server, and it makes the connection on its own, even when I forcibly disconnect before logging off.
: In Active Directory: : : Set oNet = CreateObject("Wscript.Network") : Set oUser = GetObject("WinNT://MyDomain/j_user,user") : sHomeShare = oUser.HomeDirectory : sHomeDrive = oUser.HomeDirDrive : oNet.MapNetworkDrive sHomeDrive, sHomeShare : : Could this work in an NT domain? If not, you're stuck with : net use. : : Also, I find that home drive is only mapped automatically : on W2k clients (unless you use persistent connections). : : Richard Quote: : >-----Original Message----- : >I see... : > : >"/home" is _only_ a switch for "net use". It _is_ : available if you are spawning out to a command prompt and : running something like: : > : >set oShell = CreateObject("Wscript.Shell") : >oShell.Run "%COMSPEC% /C net use H: /home" : > : >Which is what I thought you were doing. : > : >In either case, it turns out that this should be : redundant in your case. If a user is logging on to a : domain from an NT4 or Win2K : >system and has a valid drive letter and path set up in : the domain User account for their "home", the drive : mapping should occur : >automatically. : > : >If you are not getting the drive mapping to occur : automatically, there may be another issue. Try explicitly : mapping the drive from : >a command prompt and see whether it maps; if not, what : error do you get? : >
: >: The actual code I was trying is: : >: : >: Dim WshNetwork : >: Set WshNetwork = CreateObject("WScript.Network") : >: WshNetwork.MapNetworkDrive "H:", Home : >: : >: I also tried using /Home, "Home" (with the quotes), : and "/Home" - any : >: variation I could think of for the switch that works in : batch files. : >: : >: The error I get is either 'the network name cannot be : found' or 'the network : >: name does not exist' - depending on which syntax I try. : >: : >: Incidentally, I'm running this on a Win2K box, but I : get the same thing on : >: NT4. I'm aware of the Win9x problem & the need to : compensate by going to : >: sleep for a second or two, but that's not really : applicable here. : >: : >: Thanks for your response, : >: : >: Brad : >:
: without _ _> wrote in
: >: > Brad, : >: > : >: > what is the actual code you were using? : >: > : >: > The "/HOME" is a switch, not a variable, and should : work fine in a logon : >: script from WSH. Assuming you are using Win9x clients, : >: > there is another issue which can occur, where the : first attempt to make : >: use of the user name information from the WSH Network : object : >: > fails. Although you are not explicitly doing that, : it is possible that : >: the same issue is presenting you with a problem. There : are : >: > a couple of tricks that can allow you to work around : that problem : >: (involving suppressing errors, trying to get the user : name, then : >: > sleeping for a few hundred milliseconds and trying : again). : >: > : >: > If you post what you have and what errors it gives : you, it may be possible : >: to identify the issue and resolve it so you don't have : to : >: > abandon your planned approach. : >: >
: in message
: >: > : Is there a way to reference a user's home directory : in a WSH script? : >: > : : >: > : I'm trying to make a WSH script to replace our BAT : login script - but : >: while : >: > : in the BAT file I can map a drive to the user's : home directory by using : >: NET : >: > : USE H: /HOME, the WSH script does not seem to let : me use the HOME : >: variable : >: > : (it fails to map that drive). : >: > : : >: > : Does anybody know to accomplish this? : >: > : : >: > : BTW, this is for an NT4 domain - not AD. : >: > : : >: > : Thanks. : >: > : : >: > : : >: > : >: > : >: : >: : > : > : >. : >
|
Wed, 18 Aug 2004 03:41:44 GMT |
|
 |
Richard Muelle #8 / 8
|
 Mapping drive to user's home directory
I re-tested and you are right. Home drive gets mapped automatically on NT when it logs into a W2k network (I had to find a user without a logon script). Quote: >-----Original Message----- >Maybe I'm seeing a server-side thing then - I have an NT
4 client system logging in to a win2K server, and it makes the connection Quote: >on its own, even when I forcibly disconnect before logging off.
Quote: >: In Active Directory: >: >: Set oNet = CreateObject("Wscript.Network") >: Set oUser = GetObject("WinNT://MyDomain/j_user,user") >: sHomeShare = oUser.HomeDirectory >: sHomeDrive = oUser.HomeDirDrive >: oNet.MapNetworkDrive sHomeDrive, sHomeShare >: >: Could this work in an NT domain? If not, you're stuck with >: net use. >: >: Also, I find that home drive is only mapped automatically >: on W2k clients (unless you use persistent connections). >: >: Richard >: >-----Original Message----- >: >I see... >: > >: >"/home" is _only_ a switch for "net use". It _is_ >: available if you are spawning out to a command prompt and >: running something like: >: > >: >set oShell = CreateObject("Wscript.Shell") >: >oShell.Run "%COMSPEC% /C net use H: /home" >: > >: >Which is what I thought you were doing. >: > >: >In either case, it turns out that this should be >: redundant in your case. If a user is logging on to a >: domain from an NT4 or Win2K >: >system and has a valid drive letter and path set up in >: the domain User account for their "home", the drive >: mapping should occur >: >automatically. >: > >: >If you are not getting the drive mapping to occur >: automatically, there may be another issue. Try explicitly >: mapping the drive from >: >a command prompt and see whether it maps; if not, what >: error do you get? >: >
>: >: The actual code I was trying is: >: >: >: >: Dim WshNetwork >: >: Set WshNetwork = CreateObject("WScript.Network") >: >: WshNetwork.MapNetworkDrive "H:", Home >: >: >: >: I also tried using /Home, "Home" (with the quotes), >: and "/Home" - any >: >: variation I could think of for the switch that works in >: batch files. >: >: >: >: The error I get is either 'the network name cannot be >: found' or 'the network >: >: name does not exist' - depending on which syntax I try. >: >: >: >: Incidentally, I'm running this on a Win2K box, but I >: get the same thing on >: >: NT4. I'm aware of the Win9x problem & the need to >: compensate by going to >: >: sleep for a second or two, but that's not really >: applicable here. >: >: >: >: Thanks for your response, >: >: >: >: Brad >: >:
>: without _ _> wrote in
>: >: > Brad, >: >: > >: >: > what is the actual code you were using? >: >: > >: >: > The "/HOME" is a switch, not a variable, and should >: work fine in a logon >: >: script from WSH. Assuming you are using Win9x clients, >: >: > there is another issue which can occur, where the >: first attempt to make >: >: use of the user name information from the WSH Network >: object >: >: > fails. Although you are not explicitly doing that, >: it is possible that >: >: the same issue is presenting you with a problem. There >: are >: >: > a couple of tricks that can allow you to work around >: that { wh9 o1wO"a(E 0 problem >: >: (involving suppressing errors, trying to get the user >: name, then >: >: > sleeping for a few hundred milliseconds and trying >: again). >: >: > >: >: > If you post what you have and what errors it gives >: you, it may be possible >: >: to identify the issue and resolv
|
Wed, 18 Aug 2004 04:06:07 GMT |
|
|
|