vb login script not running sbsclnt.exe - MS Small Business Server
Author |
Message |
Tony Vroly #1 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
I use the following script for my Windows 2000 clients. When I use the SBS Admin Console to install new apps to these PCs the SBSCLNT.exe never seems to run. The user never gets the prompt to install or postpone. If I use a batch file with comparable actions then everything seems to work OK. This script is a compilation of examples I have seen. I am not VBScript exprt at all, so if there is an obvious problem I will not be surprised. if there are better ways to do what I am trying feel free to give examples. However most of the scripts I have seen on various support websites are way too complicated. I want something faily simple. Here are the things I would like to do... Set Time map Drives If OS = 98 copy these files Elseif OS = 2k copy those files End if If member of group X Map drive X Elseif member of group Y Map drive Y End if This would also require determining the location of certain special folders like Desktop, systemroot, program files, documents, etc. And the script must work with 98 and 2k (I know 98 must start with a batch file) In any case here is what I have so far. (ignore the reference to "C:\My documents", I know Win2k doesn't usually have this dir but I needed to use it for other reasons) If you make suggestions please be specific and complete, as I said I am still not very good with vbscript. '***start script*** Set MSIE = CreateObject("InternetExplorer.Application") Set WSHNetwork = WScript.CreateObject("WScript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") set shell = CreateObject("WScript.Shell") shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 0, false shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, false shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", 0, false MapDrive "H:","\\MLHG\CD", 0 MapDrive "J:","\\MLHG\Company", 0 MapDrive "K:","\\MLHG\Users", 0 MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\MLHGClient.mdb", "C:\My Documents\", true 'Begin subroutines Sub MapDrive(sDrive,sShare,sHome) On Error Resume Next WSHNetwork.RemoveNetworkDrive sDrive Err.Clear WSHNetwork.MapNetworkDrive sDrive,sShare MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare If sHome = 1 Then HOME = sDrive End If If Err.Number <> 0 Then MSIE.Document.Write "<BR><FONT COLOR=#FF6666>ERROR! Mapping network drive " & sDrive & " Reason: " & Err.Description & "</FONT>" NErr = 1 End if End Sub '***end script***
|
Sun, 15 May 2005 23:50:14 GMT |
|
 |
Richard Muelle #2 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Hi, A few quick comments on your code. 1. I find I cannot set the time on NT, W2k, or XP clients. Normal users don't have permission. 2. WshNetwork.UserName fails on Windows 98, due to known problem during logon. 3. In the MapDrive sub, the "If Err.Number <> 0" must come right after "WshNetwork.MapNetworkDrive". 4. In the same sub, the variable "HOME" is never used. sHome and HOME could be removed. 5. I don't know why SBSCLNT.EXE doesn't run, assuming users have permission to the share. You might want to test the execution of the exe's separately as a normal user, so you can see errors. RC = shell.Run("\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 3, True) MsgBox "RC = " & RC If you want to test group membership you must bind to the user object. You might as well use an IsMember function. As a minimum, you need the loop to retrieve UserName on Win9x clients. Some suggested code: ' Declare oGroupList so it is global in scope. Dim oGroupList ' NetBIOS Domain name. sNetBIOSDomain = "MyDomain" Set WshNetwork = CreateObject("Wscript.Network") ' Loop required for Win9x clients during logon. sNTName = "" On Error Resume Next Err.Clear Do While sNTName = "" sNTName = WshNetwork.UserName Err.Clear If Wscript.Version > 5 Then Wscript.Sleep 100 End If Loop On Error GoTo 0 ' Bind to user object with the WinNT provider. Set oUser = GetObject("WinNT://" & sNetBIOSDomain _ & "/" & sNTName & ",user") MapDrive "L:", "\\MLHG\Users\" & sNTName If IsMember("GroupX") MapDrive "J:", \\MLHG\Company" End If If IsMember("GroupY") MapDrive "K:", \\MLHG\users" End If Function IsMember(sGroup) ' Function to test for group membership. If IsEmpty(oGroupList) Then Call LoadGroups End If IsMember = oGroupList.Exists(sGroup) End Function Sub LoadGroups ' Subroutine to populate dictionary object with group ' memberships. ' oGroupList is a dictionary object, with global scope. ' oUser is the user object, with global scope. Dim oGroup Set oGroupList = CreateObject("Scripting.Dictionary") oGroupList.CompareMode = vbTextCompare For Each oGroup In oUser.Groups oGroupList(oGroup.Name) = True Next Set oGroup = Nothing End Sub Sub MapDrive(sDrive, sShare) On Error Resume Next WshNetwork.RemoveNetworkDrive sDrive Err.Clear WshNetwork.MapNetworkDrive sDrive, sShare If Err.Number <> 0 Then MSIE.Document.Write .... Else MSIE.Document.Write .... End If End Sub Richard Quote: >-----Original Message----- >I use the following script for my Windows 2000 clients. When I use the SBS >Admin Console to install new apps to these PCs the
SBSCLNT.exe never seems Quote: >to run. The user never gets the prompt to install or
postpone. If I use a Quote: >batch file with comparable actions then everything seems to work OK. >This script is a compilation of examples I have seen. I am not vbscript >exprt at all, so if there is an obvious problem I will
not be surprised. if Quote: >there are better ways to do what I am trying feel free to give examples. >However most of the scripts I have seen on various
support websites are way Quote: >too complicated. I want something faily simple. Here are the things I would >like to do... > Set Time > map Drives > If OS = 98 > copy these files > Elseif OS = 2k > copy those files > End if > If member of group X > Map drive X > Elseif member of group Y > Map drive Y > End if >This would also require determining the location of
certain special folders Quote: >like Desktop, systemroot, program files, documents, etc. And the script must >work with 98 and 2k (I know 98 must start with a batch file) >In any case here is what I have so far. (ignore the reference to "C:\My >documents", I know Win2k doesn't usually have this dir but I needed to use >it for other reasons) If you make suggestions please be specific and >complete, as I said I am still not very good with vbscript. >'***start script*** >Set MSIE = CreateObject("InternetExplorer.Application") >Set WSHNetwork = WScript.CreateObject("WScript.Network") >Set FSO = CreateObject("Scripting.FileSystemObject") >set shell = CreateObject("WScript.Shell") >shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 0, false >shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, false >shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", 0, false >MapDrive "H:","\\MLHG\CD", 0 >MapDrive "J:","\\MLHG\Company", 0 >MapDrive "K:","\\MLHG\Users", 0 >MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 >FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\M LHGClient.mdb", >"C:\My Documents\", true >'Begin subroutines >Sub MapDrive(sDrive,sShare,sHome) > On Error Resume Next > WSHNetwork.RemoveNetworkDrive sDrive > Err.Clear > WSHNetwork.MapNetworkDrive sDrive,sShare > MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare > If sHome = 1 Then > HOME = sDrive > End If > If Err.Number <> 0 Then > MSIE.Document.Write "<BR><FONT
COLOR=#FF6666>ERROR! Mapping Quote: >network drive " & sDrive & " Reason: " & Err.Description & "</FONT>" > NErr = 1 > End if >End Sub >'***end script*** >.
|
Mon, 16 May 2005 02:49:57 GMT |
|
 |
Richard Muelle #3 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Hi, Here is Torgeir Bakken's function to determine the OS. Watch for line wrapping. MsgBox GetOS Function GetOS() ' using the ver command Const OpenAsASCII = 0 Const FailIfNotExist = 0 Const ForReading = 1 Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") sTemp = oShell.ExpandEnvironmentStrings("%TEMP%") sTempFile = sTemp & "\runresult.tmp" oShell.Run "%comspec% /c ver >" & sTempFile, 0, True Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _ FailIfNotExist, OpenAsASCII) sResults = fFile.ReadAll fFile.Close oFSO.DeleteFile(sTempFile) Select Case True Case InStr(sResults, "Windows 95") > 1 : GetOS = "W95" Case InStr(sResults, "Windows 98") > 1 : GetOS = "W98" Case InStr(sResults, "Windows Millennium") > 1 : GetOS = "WME" Case InStr(sResults, "Windows NT") > 1 : GetOS = "NT4" Case InStr(sResults, "Windows 2000") > 1 : GetOS = "W2k" Case InStr(sResults, "Windows XP") > 1 : GetOS = "WXP" Case Else : GetOS = "Unknown" End Select End Function
|
Mon, 16 May 2005 02:57:46 GMT |
|
 |
Tony Vroly #4 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Thanks for the pointers. This look great. For the most part our PCs are 98 so when we added a few 2k PCs I setup their main users as local admins because I kept running into problems with them having no permissions to run certain installs I wanted them to be able to run (acrobat, WinZip and office installs along with windows update, etc.) I know there are more sophisticated ways to handle these and not give users local admin rights but I am not fluent enough in that area yet. Also we are pretty small yet with relatively intelligent users who don't go messin where they shouldn't. The worst they do is install Webshots. As my knowledge gets more complete in this area I will definitely change this policy but for lack of time I need to stick with it for now. Do not power users have permission to set time? That is the security level I envision users having locally once I can get the above issues worked out. Anyway I will try to implement the changes you suggest and post other questions as I have them. Thanks again Tony
Quote: > Hi, > A few quick comments on your code. > 1. I find I cannot set the time on NT, W2k, or XP clients. > Normal users don't have permission. > 2. WshNetwork.UserName fails on Windows 98, due to known > problem during logon. > 3. In the MapDrive sub, the "If Err.Number <> 0" must come > right after "WshNetwork.MapNetworkDrive". > 4. In the same sub, the variable "HOME" is never used. > sHome and HOME could be removed. > 5. I don't know why SBSCLNT.EXE doesn't run, assuming > users have permission to the share. You might want to test > the execution of the exe's separately as a normal user, so > you can see errors. > RC = shell.Run("\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", > 3, True) > MsgBox "RC = " & RC > If you want to test group membership you must bind to the > user object. You might as well use an IsMember function. > As a minimum, you need the loop to retrieve UserName on > Win9x clients. Some suggested code: > ' Declare oGroupList so it is global in scope. > Dim oGroupList > ' NetBIOS Domain name. > sNetBIOSDomain = "MyDomain" > Set WshNetwork = CreateObject("Wscript.Network") > ' Loop required for Win9x clients during logon. > sNTName = "" > On Error Resume Next > Err.Clear > Do While sNTName = "" > sNTName = WshNetwork.UserName > Err.Clear > If Wscript.Version > 5 Then > Wscript.Sleep 100 > End If > Loop > On Error GoTo 0 > ' Bind to user object with the WinNT provider. > Set oUser = GetObject("WinNT://" & sNetBIOSDomain _ > & "/" & sNTName & ",user") > MapDrive "L:", "\\MLHG\Users\" & sNTName > If IsMember("GroupX") > MapDrive "J:", \\MLHG\Company" > End If > If IsMember("GroupY") > MapDrive "K:", \\MLHG\users" > End If > Function IsMember(sGroup) > ' Function to test for group membership. > If IsEmpty(oGroupList) Then > Call LoadGroups > End If > IsMember = oGroupList.Exists(sGroup) > End Function > Sub LoadGroups > ' Subroutine to populate dictionary object with group > ' memberships. > ' oGroupList is a dictionary object, with global scope. > ' oUser is the user object, with global scope. > Dim oGroup > Set oGroupList = CreateObject("Scripting.Dictionary") > oGroupList.CompareMode = vbTextCompare > For Each oGroup In oUser.Groups > oGroupList(oGroup.Name) = True > Next > Set oGroup = Nothing > End Sub > Sub MapDrive(sDrive, sShare) > On Error Resume Next > WshNetwork.RemoveNetworkDrive sDrive > Err.Clear > WshNetwork.MapNetworkDrive sDrive, sShare > If Err.Number <> 0 Then > MSIE.Document.Write .... > Else > MSIE.Document.Write .... > End If > End Sub > Richard > >-----Original Message----- > >I use the following script for my Windows 2000 clients. > When I use the SBS > >Admin Console to install new apps to these PCs the > SBSCLNT.exe never seems > >to run. The user never gets the prompt to install or > postpone. If I use a > >batch file with comparable actions then everything seems > to work OK. > >This script is a compilation of examples I have seen. I > am not vbscript > >exprt at all, so if there is an obvious problem I will > not be surprised. if > >there are better ways to do what I am trying feel free to > give examples. > >However most of the scripts I have seen on various > support websites are way > >too complicated. I want something faily simple. Here are > the things I would > >like to do... > > Set Time > > map Drives > > If OS = 98 > > copy these files > > Elseif OS = 2k > > copy those files > > End if > > If member of group X > > Map drive X > > Elseif member of group Y > > Map drive Y > > End if > >This would also require determining the location of > certain special folders > >like Desktop, systemroot, program files, documents, etc. > And the script must > >work with 98 and 2k (I know 98 must start with a batch > file) > >In any case here is what I have so far. (ignore the > reference to "C:\My > >documents", I know Win2k doesn't usually have this dir > but I needed to use > >it for other reasons) If you make suggestions please be > specific and > >complete, as I said I am still not very good with > vbscript. > >'***start script*** > >Set MSIE = CreateObject("InternetExplorer.Application") > >Set WSHNetwork = WScript.CreateObject("WScript.Network") > >Set FSO = CreateObject("Scripting.FileSystemObject") > >set shell = CreateObject("WScript.Shell") > >shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 0, > false > >shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, false > >shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", 0, > false > >MapDrive "H:","\\MLHG\CD", 0 > >MapDrive "J:","\\MLHG\Company", 0 > >MapDrive "K:","\\MLHG\Users", 0 > >MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 > >FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\M > LHGClient.mdb", > >"C:\My Documents\", true > >'Begin subroutines > >Sub MapDrive(sDrive,sShare,sHome) > > On Error Resume Next > > WSHNetwork.RemoveNetworkDrive sDrive > > Err.Clear > > WSHNetwork.MapNetworkDrive sDrive,sShare > > MSIE.Document.Write "<BR>Mapping " & sDrive & " to " > & sShare > > If sHome = 1 Then > > HOME = sDrive > > End If > > If Err.Number <> 0 Then > > MSIE.Document.Write "<BR><FONT > COLOR=#FF6666>ERROR! Mapping > >network drive " & sDrive & " Reason: " & Err.Description > & "</FONT>" > > NErr = 1 > > End if > >End Sub > >'***end script*** > >.
|
Mon, 16 May 2005 03:58:23 GMT |
|
 |
MV #5 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Quote:
> This would also require determining the location of certain special folders > like Desktop, systemroot, program files, documents, etc. And the script must > work with 98 and 2k (I know 98 must start with a batch file)
Hi I recommend that you get system paths through: WSH FileSystemObject's GetSpecialFolder method WSH Shell's SpecialFolders property or if not obtainable from the above, use: OS Environment Registry For a discussion about SpecialFolders, see this tread: Subject: How do I find the name of OS specific folders like (C:\Documents and Settings\All Users\Application Data\) Newsgroups: microsoft.public.scripting.vbscript Date: 2002-09-19 07:50:06 PST http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=cb5a92... With WSH FileSystemObject's GetSpecialFolder method, you can get to the Windows folder, Windows system folder and temp folder: Set oFSO = CreateObject("Scripting.FileSystemObject") sWinDir = oFSO.GetSpecialFolder(0) sWinSysDir = oFSO.GetSpecialFolder(1) sTempDir = oFSO.GetSpecialFolder(2) Here is a script that gets the %Program Files% path: ' for the path to "Program Files" you must use OS environment/registry read Set oShell = CreateObject("WScript.Shell") Set oProcEnv = oShell.Environment("PROCESS") sProgramFiles = oProcEnv("ProgramFiles") If sProgramFiles = "" Then sProgramFiles = oShell.RegRead _ ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir") End If WScript.Echo sProgramFiles -- torgeir Microsoft MVP Scripting and WMI Porsgrunn Norway
|
Mon, 16 May 2005 04:11:55 GMT |
|
 |
MV #6 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Quote:
> Do not power users have permission to set time? That is the security level I > envision users having locally once I can get the above issues worked out.
Hi No, they can't set the time. If you make the Win2k computers members of a domain later on, the computers will get the time from the domain controller. -- torgeir Microsoft MVP Scripting and WMI Porsgrunn Norway
|
Mon, 16 May 2005 04:16:44 GMT |
|
 |
Tony Vroly #7 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
That is good info, thanks. Then they should already be getting time from the domain controller as they must join the domain in order to login, etc. Then I could use something this If OS = 98 then set time end if
Quote:
> > Do not power users have permission to set time? That is the security level I > > envision users having locally once I can get the above issues worked out. > Hi > No, they can't set the time. If you make the Win2k computers members of a domain > later on, the computers will get the time from the domain controller. > -- > torgeir > Microsoft MVP Scripting and WMI > Porsgrunn Norway
|
Mon, 16 May 2005 05:01:32 GMT |
|
 |
Tony Vroly #8 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
More great info - why the heck didn't I post here a long tim ago? Any suggestions for getting the location of the users document folder? I have re-directed all users "My Documents" to their home dir on the server. However when I want to copy a file to all users doc dir, rather than copy/pasting ump{*filter*} times for each dir, I could just put it in the script. thanks again tony
Quote:
> > This would also require determining the location of certain special folders > > like Desktop, systemroot, program files, documents, etc. And the script must > > work with 98 and 2k (I know 98 must start with a batch file) > Hi > I recommend that you get system paths through: > WSH FileSystemObject's GetSpecialFolder method > WSH Shell's SpecialFolders property > or if not obtainable from the above, use: > OS Environment > Registry > For a discussion about SpecialFolders, see this tread: > Subject: How do I find the name of OS specific folders like (C:\Documents and > Settings\All Users\Application Data\) > Newsgroups: microsoft.public.scripting.vbscript > Date: 2002-09-19 07:50:06 PST
http://www.*-*-*.com/ d03 Quote: > With WSH FileSystemObject's GetSpecialFolder method, you can get to the Windows > folder, Windows system folder and temp folder: > Set oFSO = CreateObject("Scripting.FileSystemObject") > sWinDir = oFSO.GetSpecialFolder(0) > sWinSysDir = oFSO.GetSpecialFolder(1) > sTempDir = oFSO.GetSpecialFolder(2) > Here is a script that gets the %Program Files% path: > ' for the path to "Program Files" you must use OS environment/registry read > Set oShell = CreateObject("WScript.Shell") > Set oProcEnv = oShell.Environment("PROCESS") > sProgramFiles = oProcEnv("ProgramFiles") > If sProgramFiles = "" Then > sProgramFiles = oShell.RegRead _ > ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir") > End If > WScript.Echo sProgramFiles > -- > torgeir > Microsoft MVP Scripting and WMI > Porsgrunn Norway
|
Mon, 16 May 2005 05:05:07 GMT |
|
 |
Tony Vroly #9 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
One problem. I think I have assembled a script that will serve my needs. I am testing it on my machine which is Win2k SP3 and the script is tripping up on the line: Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sNTName & ",user") I get this error: Script = <scripte path/name> Line = 21 Char = 1 Error = 0x80005000 coden = 80005000 source = (null) Did I{*filter*}something up when I copied it over? BTW is there a reason shy functions should appear before Subs? I noticed that is how you had in your sample. Or is that just how you happen to type it. Here is my whole script so far. I hope I have adapted it well. A few more changes pending. Sorry about word wrap. '****script start**** Dim oGroupList Set MSIE = CreateObject("InternetExplorer.Application") Set WSHNetwork = WScript.CreateObject("WScript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") set shell = CreateObject("WScript.Shell") ' Loop required for Win9x clients during logon. sNTName = "" On Error Resume Next Err.Clear Do While sNTName = "" sNTName = WshNetwork.UserName Err.Clear If Wscript.Version > 5 Then Wscript.Sleep 100 End If Loop On Error GoTo 0 ' Bind to user object with the WinNT provider. Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sNTName & ",user") 'MapDrive "H:","\\server\CD", 0 MapDrive "J:","\\server\Company", 0 MapDrive "K:","\\server\Users", 0 MapDrive "L:","\\server\USERS\" & WshNetwork.UserName , 1 FSO.CopyFile "\\server\Company\Documents\Database\FrontEnd\MLHGClient.mdb, "C:\My Documents\", true If IsMember("GroupA") then MapDrive "M:","\\server\MFA", 0 FSO.CopyFile "\\server\MFA\Database\FrontEnd\MFAClient.mdb, "C:\My Documents\", true End If shell.Run "\\server\Clients\Setup\SBSCLNT.exe /s server", 3, false shell.Run "\\server\OFFICESCAN\PCCSRV\AUTOPCC.EXE, 0, false If GetOS = "Win9x" then shell.Run "%comspec% /c NET TIME \\server /SET /YES /Y", 0, false End If 'Begin functions Function IsMember(sGroup) ' Function to test for group membership. If IsEmpty(oGroupList) Then Call LoadGroups End If IsMember = oGroupList.Exists(sGroup) End Function Function GetOS() ' using the ver command Const OpenAsASCII = 0 Const FailIfNotExist = 0 Const ForReading = 1 Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") sTemp = oShell.ExpandEnvironmentStrings("%TEMP%") sTempFile = sTemp & "\runresult.tmp" oShell.Run "%comspec% /c ver >" & sTempFile, 0, True Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsASCII) sResults = fFile.ReadAll fFile.Close oFSO.DeleteFile(sTempFile) Select Case True Case InStr(sResults, "Windows 95") > 1 : GetOS = "Win9x" Case InStr(sResults, "Windows 98") > 1 : GetOS = "Win9x" Case InStr(sResults, "Windows Millennium") > 1 : GetOS = "Win9x" Case InStr(sResults, "Windows NT") > 1 : GetOS = "WinNT4" Case InStr(sResults, "Windows 2000") > 1 : GetOS = "Win2k" Case InStr(sResults, "Windows XP") > 1 : GetOS = "WinXP" Case Else : GetOS = "Unknown" End Select End Function 'Begin subroutines Sub LoadGroups ' Subroutine to populate dictionary object with group ' memberships. ' oGroupList is a dictionary object, with global scope. ' oUser is the user object, with global scope. Dim oGroup Set oGroupList = CreateObject("Scripting.Dictionary") oGroupList.CompareMode = vbTextCompare For Each oGroup In oUser.Groups oGroupList(oGroup.Name) = True Next Set oGroup = Nothing End Sub Sub MapDrive(sDrive, sShare) On Error Resume Next WshNetwork.RemoveNetworkDrive sDrive Err.Clear WshNetwork.MapNetworkDrive sDrive, sShare If Err.Number <> 0 Then MSIE.Document.Write "<BR><FONT COLOR=#FF6666>ERROR! Mapping network drive " & sDrive & " Reason: " & Err.Description & "</FONT>" NErr = 1 'Else ' MSIE.Document.Write .... End If End Sub Sub MapDrive(sDrive,sShare,sHome) On Error Resume Next WSHNetwork.RemoveNetworkDrive sDrive Err.Clear WSHNetwork.MapNetworkDrive sDrive,sShare MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare If sHome = 1 Then HOME = sDrive End If if Err.Number <> 0 Then MSIE.Document.Write End if End Sub '****script end****
Quote: > Hi, > A few quick comments on your code. > 1. I find I cannot set the time on NT, W2k, or XP clients. > Normal users don't have permission. > 2. WshNetwork.UserName fails on Windows 98, due to known > problem during logon. > 3. In the MapDrive sub, the "If Err.Number <> 0" must come > right after "WshNetwork.MapNetworkDrive". > 4. In the same sub, the variable "HOME" is never used. > sHome and HOME could be removed. > 5. I don't know why SBSCLNT.EXE doesn't run, assuming > users have permission to the share. You might want to test > the execution of the exe's separately as a normal user, so > you can see errors.
....................
|
Mon, 16 May 2005 05:22:02 GMT |
|
 |
MV #10 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Quote:
> More great info - why the heck didn't I post here a long tim ago? > Any suggestions for getting the location of the users document folder? I > have re-directed all users "My Documents" to their home dir on the server. > However when I want to copy a file to all users doc dir, rather than > copy/pasting ump{*filter*} times for each dir, I could just put it in the script.
Hi That one was listed in the SpecialFolders list: Set oShell = CreateObject("WScript.Shell") sMyDocumentsr = oShell.SpecialFolders("MyDocuments") Wscript.Echo sMyDocuments -- torgeir Microsoft MVP Scripting and WMI Porsgrunn Norway
|
Mon, 16 May 2005 05:21:49 GMT |
|
 |
Tony Vroly #11 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Sorry I missed that, thanks
Quote:
> > More great info - why the heck didn't I post here a long tim ago? > > Any suggestions for getting the location of the users document folder? I > > have re-directed all users "My Documents" to their home dir on the server. > > However when I want to copy a file to all users doc dir, rather than > > copy/pasting ump{*filter*} times for each dir, I could just put it in the script. > Hi > That one was listed in the SpecialFolders list: > Set oShell = CreateObject("WScript.Shell") > sMyDocumentsr = oShell.SpecialFolders("MyDocuments") > Wscript.Echo sMyDocuments > -- > torgeir > Microsoft MVP Scripting and WMI > Porsgrunn Norway
|
Mon, 16 May 2005 05:38:46 GMT |
|
 |
Tony Vroly #12 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
One more problem. I apparently, as local admin and domain admin, do not have permission to the All Users desktop. I used this simple script and I get a "Permission Denied" error. '***start*** Set FSO = CreateObject("Scripting.FileSystemObject") set shell = CreateObject("WScript.Shell") AllDesktopDir = Shell.SpecialFolders("AllUsersDesktop") If Not Fso.FileExists (AllDesktopDir & "\MLHG clients.lnk") Then MsgBox "File Does Not Exist" FSO.CopyFile "\\server\some dir\MLHG Clients.lnk", AllDesktopDir , true End If '***end***
Quote: > Hi, > A few quick comments on your code. > 1. I find I cannot set the time on NT, W2k, or XP clients. > Normal users don't have permission. > 2. WshNetwork.UserName fails on Windows 98, due to known > problem during logon. > 3. In the MapDrive sub, the "If Err.Number <> 0" must come > right after "WshNetwork.MapNetworkDrive". > 4. In the same sub, the variable "HOME" is never used. > sHome and HOME could be removed. > 5. I don't know why SBSCLNT.EXE doesn't run, assuming > users have permission to the share. You might want to test > the execution of the exe's separately as a normal user, so > you can see errors. > RC = shell.Run("\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", > 3, True) > MsgBox "RC = " & RC > If you want to test group membership you must bind to the > user object. You might as well use an IsMember function. > As a minimum, you need the loop to retrieve UserName on > Win9x clients. Some suggested code: > ' Declare oGroupList so it is global in scope. > Dim oGroupList > ' NetBIOS Domain name. > sNetBIOSDomain = "MyDomain" > Set WshNetwork = CreateObject("Wscript.Network") > ' Loop required for Win9x clients during logon. > sNTName = "" > On Error Resume Next > Err.Clear > Do While sNTName = "" > sNTName = WshNetwork.UserName > Err.Clear > If Wscript.Version > 5 Then > Wscript.Sleep 100 > End If > Loop > On Error GoTo 0 > ' Bind to user object with the WinNT provider. > Set oUser = GetObject("WinNT://" & sNetBIOSDomain _ > & "/" & sNTName & ",user") > MapDrive "L:", "\\MLHG\Users\" & sNTName > If IsMember("GroupX") > MapDrive "J:", \\MLHG\Company" > End If > If IsMember("GroupY") > MapDrive "K:", \\MLHG\users" > End If > Function IsMember(sGroup) > ' Function to test for group membership. > If IsEmpty(oGroupList) Then > Call LoadGroups > End If > IsMember = oGroupList.Exists(sGroup) > End Function > Sub LoadGroups > ' Subroutine to populate dictionary object with group > ' memberships. > ' oGroupList is a dictionary object, with global scope. > ' oUser is the user object, with global scope. > Dim oGroup > Set oGroupList = CreateObject("Scripting.Dictionary") > oGroupList.CompareMode = vbTextCompare > For Each oGroup In oUser.Groups > oGroupList(oGroup.Name) = True > Next > Set oGroup = Nothing > End Sub > Sub MapDrive(sDrive, sShare) > On Error Resume Next > WshNetwork.RemoveNetworkDrive sDrive > Err.Clear > WshNetwork.MapNetworkDrive sDrive, sShare > If Err.Number <> 0 Then > MSIE.Document.Write .... > Else > MSIE.Document.Write .... > End If > End Sub > Richard > >-----Original Message----- > >I use the following script for my Windows 2000 clients. > When I use the SBS > >Admin Console to install new apps to these PCs the > SBSCLNT.exe never seems > >to run. The user never gets the prompt to install or > postpone. If I use a > >batch file with comparable actions then everything seems > to work OK. > >This script is a compilation of examples I have seen. I > am not vbscript > >exprt at all, so if there is an obvious problem I will > not be surprised. if > >there are better ways to do what I am trying feel free to > give examples. > >However most of the scripts I have seen on various > support websites are way > >too complicated. I want something faily simple. Here are > the things I would > >like to do... > > Set Time > > map Drives > > If OS = 98 > > copy these files > > Elseif OS = 2k > > copy those files > > End if > > If member of group X > > Map drive X > > Elseif member of group Y > > Map drive Y > > End if > >This would also require determining the location of > certain special folders > >like Desktop, systemroot, program files, documents, etc. > And the script must > >work with 98 and 2k (I know 98 must start with a batch > file) > >In any case here is what I have so far. (ignore the > reference to "C:\My > >documents", I know Win2k doesn't usually have this dir > but I needed to use > >it for other reasons) If you make suggestions please be > specific and > >complete, as I said I am still not very good with > vbscript. > >'***start script*** > >Set MSIE = CreateObject("InternetExplorer.Application") > >Set WSHNetwork = WScript.CreateObject("WScript.Network") > >Set FSO = CreateObject("Scripting.FileSystemObject") > >set shell = CreateObject("WScript.Shell") > >shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 0, > false > >shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, false > >shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", 0, > false > >MapDrive "H:","\\MLHG\CD", 0 > >MapDrive "J:","\\MLHG\Company", 0 > >MapDrive "K:","\\MLHG\Users", 0 > >MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 > >FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\M > LHGClient.mdb", > >"C:\My Documents\", true > >'Begin subroutines > >Sub MapDrive(sDrive,sShare,sHome) > > On Error Resume Next > > WSHNetwork.RemoveNetworkDrive sDrive > > Err.Clear > > WSHNetwork.MapNetworkDrive sDrive,sShare > > MSIE.Document.Write "<BR>Mapping " & sDrive & " to " > & sShare > > If sHome = 1 Then > > HOME = sDrive > > End If > > If Err.Number <> 0 Then > > MSIE.Document.Write "<BR><FONT > COLOR=#FF6666>ERROR! Mapping > >network drive " & sDrive & " Reason: " & Err.Description > & "</FONT>" > > NErr = 1 > > End if > >End Sub > >'***end script*** > >.
|
Mon, 16 May 2005 06:47:35 GMT |
|
 |
Richard Muelle #13 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Hi, You need to either assign the variable sNetBIOSDomain to be your domain name, or hard code the domain name in the Set statement: sNetBIOSDomain = "YourDomainName" or Set oUser = GetObject("WinNT://MyDomain/" & sNTName _ & ",user") Also, Functions and Subs can appear anywhere in any order. Richard Quote: >-----Original Message----- >One problem. >I think I have assembled a script that will serve my
needs. I am testing it Quote: >on my machine which is Win2k SP3 and the script is
tripping up on the line: Quote: > Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sNTName & >",user") >I get this error: >Script = <scripte path/name> >Line = 21 >Char = 1 >Error = 0x80005000 >coden = 80005000 >source = (null) >Did I{*filter*}something up when I copied it over? >BTW is there a reason shy functions should appear before Subs? I noticed >that is how you had in your sample. Or is that just how you happen to type >it. >Here is my whole script so far. I hope I have adapted it well. A few more >changes pending. Sorry about word wrap. >'****script start**** >Dim oGroupList >Set MSIE = CreateObject("InternetExplorer.Application") >Set WSHNetwork = WScript.CreateObject("WScript.Network") >Set FSO = CreateObject("Scripting.FileSystemObject") >set shell = CreateObject("WScript.Shell") >' Loop required for Win9x clients during logon. >sNTName = "" >On Error Resume Next >Err.Clear >Do While sNTName = "" > sNTName = WshNetwork.UserName > Err.Clear > If Wscript.Version > 5 Then > Wscript.Sleep 100 > End If >Loop >On Error GoTo 0 >' Bind to user object with the WinNT provider. >Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sNTName & ",user") >'MapDrive "H:","\\server\CD", 0 >MapDrive "J:","\\server\Company", 0 >MapDrive "K:","\\server\Users", 0 >MapDrive "L:","\\server\USERS\" & WshNetwork.UserName , 1 >FSO.CopyFile "\\server\Company\Documents\Database\FrontEnd \MLHGClient.mdb, >"C:\My Documents\", true >If IsMember("GroupA") then > MapDrive "M:","\\server\MFA", 0
FSO.CopyFile "\\server\MFA\Database\FrontEnd\MFAClient.mdb, "C:\My Quote: >Documents\", true >End If >shell.Run "\\server\Clients\Setup\SBSCLNT.exe /s server", 3, false >shell.Run "\\server\OFFICESCAN\PCCSRV\AUTOPCC.EXE, 0, false >If GetOS = "Win9x" then > shell.Run "%comspec% /c NET TIME
\\server /SET /YES /Y", 0, false Quote: >End If >'Begin functions >Function IsMember(sGroup) >' Function to test for group membership. > If IsEmpty(oGroupList) Then > Call LoadGroups > End If > IsMember = oGroupList.Exists(sGroup) >End Function >Function GetOS() > ' using the ver command > Const OpenAsASCII = 0 > Const FailIfNotExist = 0 > Const ForReading = 1 > Set oShell = CreateObject("WScript.Shell") > Set oFSO = CreateObject("Scripting.FileSystemObject") > sTemp = oShell.ExpandEnvironmentStrings("%TEMP%") > sTempFile = sTemp & "\runresult.tmp" > oShell.Run "%comspec% /c ver >" & sTempFile, 0, True > Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, >OpenAsASCII) > sResults = fFile.ReadAll > fFile.Close > oFSO.DeleteFile(sTempFile) > Select Case True > Case InStr(sResults, "Windows 95") > 1 : GetOS = "Win9x" > Case InStr(sResults, "Windows 98") > 1 : GetOS = "Win9x" > Case InStr(sResults, "Windows Millennium") > 1 : GetOS = "Win9x" > Case InStr(sResults, "Windows NT") > 1 : GetOS = "WinNT4" > Case InStr(sResults, "Windows 2000") > 1 : GetOS = "Win2k" > Case InStr(sResults, "Windows XP") > 1 : GetOS = "WinXP" > Case Else : GetOS = "Unknown" > End Select >End Function >'Begin subroutines >Sub LoadGroups >' Subroutine to populate dictionary object with group >' memberships. >' oGroupList is a dictionary object, with global scope. >' oUser is the user object, with global scope. > Dim oGroup > Set oGroupList = CreateObject("Scripting.Dictionary") > oGroupList.CompareMode = vbTextCompare > For Each oGroup In oUser.Groups > oGroupList(oGroup.Name) = True > Next > Set oGroup = Nothing >End Sub >Sub MapDrive(sDrive, sShare) > On Error Resume Next > WshNetwork.RemoveNetworkDrive sDrive > Err.Clear > WshNetwork.MapNetworkDrive sDrive, sShare > If Err.Number <> 0 Then > MSIE.Document.Write "<BR><FONT COLOR=#FF6666>ERROR! Mapping network >drive " & sDrive & " Reason: " & Err.Description & "</FONT>" > NErr = 1 > 'Else > ' MSIE.Document.Write .... > End If >End Sub >Sub MapDrive(sDrive,sShare,sHome) > On Error Resume Next > WSHNetwork.RemoveNetworkDrive sDrive > Err.Clear > WSHNetwork.MapNetworkDrive sDrive,sShare > MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare > If sHome = 1 Then > HOME = sDrive > End If > if Err.Number <> 0 Then > MSIE.Document.Write > End if >End Sub >'****script end****
message
>> Hi, >> A few quick comments on your code. >> 1. I find I cannot set the time on NT, W2k, or XP clients. >> Normal users don't have permission. >> 2. WshNetwork.UserName fails on Windows 98, due to known >> problem during logon. >> 3. In the MapDrive sub, the "If Err.Number <> 0" must come >> right after "WshNetwork.MapNetworkDrive". >> 4. In the same sub, the variable "HOME" is never used. >> sHome and HOME could be removed. >> 5. I don't know why SBSCLNT.EXE doesn't run, assuming >> users have permission to the share. You might want to test >> the execution of the exe's separately as a normal user, so >> you can see errors. >..................... >.
|
Mon, 16 May 2005 08:10:18 GMT |
|
 |
Richard Muelle #14 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
Hi, I got the same error. Fix is to add a trailing backslash to the destination folder name, so that FSO knows it is a folder and not a file name. FSO.CopyFile "\\server\some dir\MLHG Clients.lnk", AllDesktopDir & "\" , true Richard Quote: >-----Original Message----- >One more problem. I apparently, as local admin and domain admin, do not have >permission to the All Users desktop. I used this simple script and I get a >"Permission Denied" error. >'***start*** >Set FSO = CreateObject("Scripting.FileSystemObject") >set shell = CreateObject("WScript.Shell") >AllDesktopDir = Shell.SpecialFolders("AllUsersDesktop") >If Not Fso.FileExists (AllDesktopDir & "\MLHG clients.lnk") Then > MsgBox "File Does Not Exist" > FSO.CopyFile "\\server\some dir\MLHG Clients.lnk",
AllDesktopDir , true Quote: >End If >'***end***
message
>> Hi, >> A few quick comments on your code. >> 1. I find I cannot set the time on NT, W2k, or XP clients. >> Normal users don't have permission. >> 2. WshNetwork.UserName fails on Windows 98, due to known >> problem during logon. >> 3. In the MapDrive sub, the "If Err.Number <> 0" must come >> right after "WshNetwork.MapNetworkDrive". >> 4. In the same sub, the variable "HOME" is never used. >> sHome and HOME could be removed. >> 5. I don't know why SBSCLNT.EXE doesn't run, assuming >> users have permission to the share. You might want to test >> the execution of the exe's separately as a normal user, so >> you can see errors. >> RC = shell.Run("\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", >> 3, True) >> MsgBox "RC = " & RC >> If you want to test group membership you must bind to the >> user object. You might as well use an IsMember function. >> As a minimum, you need the loop to retrieve UserName on >> Win9x clients. Some suggested code: >> ' Declare oGroupList so it is global in scope. >> Dim oGroupList >> ' NetBIOS Domain name. >> sNetBIOSDomain = "MyDomain" >> Set WshNetwork = CreateObject("Wscript.Network") >> ' Loop required for Win9x clients during logon. >> sNTName = "" >> On Error Resume Next >> Err.Clear >> Do While sNTName = "" >> sNTName = WshNetwork.UserName >> Err.Clear >> If Wscript.Version > 5 Then >> Wscript.Sleep 100 >> End If >> Loop >> On Error GoTo 0 >> ' Bind to user object with the WinNT provider. >> Set oUser = GetObject("WinNT://" & sNetBIOSDomain _ >> & "/" & sNTName & ",user") >> MapDrive "L:", "\\MLHG\Users\" & sNTName >> If IsMember("GroupX") >> MapDrive "J:", \\MLHG\Company" >> End If >> If IsMember("GroupY") >> MapDrive "K:", \\MLHG\users" >> End If >> Function IsMember(sGroup) >> ' Function to test for group membership. >> If IsEmpty(oGroupList) Then >> Call LoadGroups >> End If >> IsMember = oGroupList.Exists(sGroup) >> End Function >> Sub LoadGroups >> ' Subroutine to populate dictionary object with group >> ' memberships. >> ' oGroupList is a dictionary object, with global scope. >> ' oUser is the user object, with global scope. >> Dim oGroup >> Set oGroupList = CreateObject("Scripting.Dictionary") >> oGroupList.CompareMode = vbTextCompare >> For Each oGroup In oUser.Groups >> oGroupList(oGroup.Name) = True >> Next >> Set oGroup = Nothing >> End Sub >> Sub MapDrive(sDrive, sShare) >> On Error Resume Next >> WshNetwork.RemoveNetworkDrive sDrive >> Err.Clear >> WshNetwork.MapNetworkDrive sDrive, sShare >> If Err.Number <> 0 Then >> MSIE.Document.Write .... >> Else >> MSIE.Document.Write .... >> End If >> End Sub >> Richard >> >-----Original Message----- >> >I use the following script for my Windows 2000 clients. >> When I use the SBS >> >Admin Console to install new apps to these PCs the >> SBSCLNT.exe never seems >> >to run. The user never gets the prompt to install or >> postpone. If I use a >> >batch file with comparable actions then everything seems >> to work OK. >> >This script is a compilation of examples I have seen. I >> am not vbscript >> >exprt at all, so if there is an obvious problem I will >> not be surprised. if >> >there are better ways to do what I am trying feel free to >> give examples. >> >However most of the scripts I have seen on various >> support websites are way >> >too complicated. I want something faily simple. Here are >> the things I would >> >like to do... >> > Set Time >> > map Drives >> > If OS = 98 >> > copy these files >> > Elseif OS = 2k >> > copy those files >> > End if >> > If member of group X >> > Map drive X >> > Elseif member of group Y >> > Map drive Y >> > End if >> >This would also require determining the location of >> certain special folders >> >like Desktop, systemroot, program files, documents, etc. >> And the script must >> >work with 98 and 2k (I know 98 must start with a batch >> file) >> >In any case here is what I have so far. (ignore the >> reference to "C:\My >> >documents", I know Win2k doesn't usually have this dir >> but I needed to use >> >it for other reasons) If you make suggestions please be >> specific and >> >complete, as I said I am still not very good with >> vbscript. >> >'***start script*** >> >Set MSIE = CreateObject("InternetExplorer.Application") >> >Set WSHNetwork = WScript.CreateObject ("WScript.Network") >> >Set FSO = CreateObject("Scripting.FileSystemObject") >> >set shell = CreateObject("WScript.Shell") >> >shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", 0, >> false >> >shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, false >> >shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", 0, >> false >> >MapDrive "H:","\\MLHG\CD", 0 >> >MapDrive "J:","\\MLHG\Company", 0 >> >MapDrive "K:","\\MLHG\Users", 0 >> >MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 >FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\M >> LHGClient.mdb", >> >"C:\My Documents\", true >> >'Begin subroutines >> >Sub MapDrive(sDrive,sShare,sHome) >> > On Error Resume Next >> > WSHNetwork.RemoveNetworkDrive sDrive >> > Err.Clear >> > WSHNetwork.MapNetworkDrive sDrive,sShare >> > MSIE.Document.Write "<BR>Mapping " & sDrive & " to " >> & sShare >> > If sHome = 1 Then >> > HOME = sDrive >> > End If >> > If Err.Number <> 0 Then >> > MSIE.Document.Write "<BR><FONT >> COLOR=#FF6666>ERROR! Mapping >> >network drive " & sDrive & " Reason: " & Err.Description >> & "</FONT>" >> > NErr = 1 >> > End if >> >End Sub >> >'***end script*** >> >. >.
|
Mon, 16 May 2005 08:25:21 GMT |
|
 |
Tony Vroly #15 / 17
|
 vb login script not running sbsclnt.exe - MS Small Business Server
That got things going! Along with the other fis about the domain name. Now it seems all is working on my machine. I will run it on some 98 machines to test and then implement. Thanks a lot for your help. This has been a learning experience. Like I said before, why didn't I post here a lonmg time ago? Tony
Quote: > Hi, > I got the same error. Fix is to add a trailing backslash > to the destination folder name, so that FSO knows it is a > folder and not a file name. > FSO.CopyFile "\\server\some dir\MLHG Clients.lnk", > AllDesktopDir & "\" , true > Richard > >-----Original Message----- > >One more problem. I apparently, as local admin and domain > admin, do not have > >permission to the All Users desktop. I used this simple > script and I get a > >"Permission Denied" error. > >'***start*** > >Set FSO = CreateObject("Scripting.FileSystemObject") > >set shell = CreateObject("WScript.Shell") > >AllDesktopDir = Shell.SpecialFolders("AllUsersDesktop") > >If Not Fso.FileExists (AllDesktopDir & "\MLHG > clients.lnk") Then > > MsgBox "File Does Not Exist" > > FSO.CopyFile "\\server\some dir\MLHG Clients.lnk", > AllDesktopDir , true > >End If > >'***end***
> message
> >> Hi, > >> A few quick comments on your code. > >> 1. I find I cannot set the time on NT, W2k, or XP > clients. > >> Normal users don't have permission. > >> 2. WshNetwork.UserName fails on Windows 98, due to known > >> problem during logon. > >> 3. In the MapDrive sub, the "If Err.Number <> 0" must > come > >> right after "WshNetwork.MapNetworkDrive". > >> 4. In the same sub, the variable "HOME" is never used. > >> sHome and HOME could be removed. > >> 5. I don't know why SBSCLNT.EXE doesn't run, assuming > >> users have permission to the share. You might want to > test > >> the execution of the exe's separately as a normal user, > so > >> you can see errors. > >> RC = shell.Run("\\MLHG\Clients\Setup\SBSCLNT.exe /s > MLHG", > >> 3, True) > >> MsgBox "RC = " & RC > >> If you want to test group membership you must bind to > the > >> user object. You might as well use an IsMember function. > >> As a minimum, you need the loop to retrieve UserName on > >> Win9x clients. Some suggested code: > >> ' Declare oGroupList so it is global in scope. > >> Dim oGroupList > >> ' NetBIOS Domain name. > >> sNetBIOSDomain = "MyDomain" > >> Set WshNetwork = CreateObject("Wscript.Network") > >> ' Loop required for Win9x clients during logon. > >> sNTName = "" > >> On Error Resume Next > >> Err.Clear > >> Do While sNTName = "" > >> sNTName = WshNetwork.UserName > >> Err.Clear > >> If Wscript.Version > 5 Then > >> Wscript.Sleep 100 > >> End If > >> Loop > >> On Error GoTo 0 > >> ' Bind to user object with the WinNT provider. > >> Set oUser = GetObject("WinNT://" & sNetBIOSDomain _ > >> & "/" & sNTName & ",user") > >> MapDrive "L:", "\\MLHG\Users\" & sNTName > >> If IsMember("GroupX") > >> MapDrive "J:", \\MLHG\Company" > >> End If > >> If IsMember("GroupY") > >> MapDrive "K:", \\MLHG\users" > >> End If > >> Function IsMember(sGroup) > >> ' Function to test for group membership. > >> If IsEmpty(oGroupList) Then > >> Call LoadGroups > >> End If > >> IsMember = oGroupList.Exists(sGroup) > >> End Function > >> Sub LoadGroups > >> ' Subroutine to populate dictionary object with group > >> ' memberships. > >> ' oGroupList is a dictionary object, with global scope. > >> ' oUser is the user object, with global scope. > >> Dim oGroup > >> Set oGroupList = CreateObject("Scripting.Dictionary") > >> oGroupList.CompareMode = vbTextCompare > >> For Each oGroup In oUser.Groups > >> oGroupList(oGroup.Name) = True > >> Next > >> Set oGroup = Nothing > >> End Sub > >> Sub MapDrive(sDrive, sShare) > >> On Error Resume Next > >> WshNetwork.RemoveNetworkDrive sDrive > >> Err.Clear > >> WshNetwork.MapNetworkDrive sDrive, sShare > >> If Err.Number <> 0 Then > >> MSIE.Document.Write .... > >> Else > >> MSIE.Document.Write .... > >> End If > >> End Sub > >> Richard > >> >-----Original Message----- > >> >I use the following script for my Windows 2000 clients. > >> When I use the SBS > >> >Admin Console to install new apps to these PCs the > >> SBSCLNT.exe never seems > >> >to run. The user never gets the prompt to install or > >> postpone. If I use a > >> >batch file with comparable actions then everything > seems > >> to work OK. > >> >This script is a compilation of examples I have seen. I > >> am not vbscript > >> >exprt at all, so if there is an obvious problem I will > >> not be surprised. if > >> >there are better ways to do what I am trying feel free > to > >> give examples. > >> >However most of the scripts I have seen on various > >> support websites are way > >> >too complicated. I want something faily simple. Here > are > >> the things I would > >> >like to do... > >> > Set Time > >> > map Drives > >> > If OS = 98 > >> > copy these files > >> > Elseif OS = 2k > >> > copy those files > >> > End if > >> > If member of group X > >> > Map drive X > >> > Elseif member of group Y > >> > Map drive Y > >> > End if > >> >This would also require determining the location of > >> certain special folders > >> >like Desktop, systemroot, program files, documents, > etc. > >> And the script must > >> >work with 98 and 2k (I know 98 must start with a batch > >> file) > >> >In any case here is what I have so far. (ignore the > >> reference to "C:\My > >> >documents", I know Win2k doesn't usually have this dir > >> but I needed to use > >> >it for other reasons) If you make suggestions please be > >> specific and > >> >complete, as I said I am still not very good with > >> vbscript. > >> >'***start script*** > >> >Set MSIE = CreateObject("InternetExplorer.Application") > >> >Set WSHNetwork = WScript.CreateObject > ("WScript.Network") > >> >Set FSO = CreateObject("Scripting.FileSystemObject") > >> >set shell = CreateObject("WScript.Shell") > >> >shell.Run "\\MLHG\Clients\Setup\SBSCLNT.exe /s MLHG", > 0, > >> false > >> >shell.Run "\\MLHG\OFFICESCAN\PCCSRV\AUTOPCC.EXE", 0, > false > >> >shell.Run "%comspec% /c NET TIME \\MLHG /SET /YES /Y", > 0, > >> false > >> >MapDrive "H:","\\MLHG\CD", 0 > >> >MapDrive "J:","\\MLHG\Company", 0 > >> >MapDrive "K:","\\MLHG\Users", 0 > >> >MapDrive "L:","\\MLHG\USERS\" & WshNetwork.UserName , 1 > >FSO.CopyFile "\\MLHG\Company\Documents\Database\FrontEnd\M > >> LHGClient.mdb", > >> >"C:\My Documents\", true > >> >'Begin subroutines > >> >Sub MapDrive(sDrive,sShare,sHome) > >> > On Error Resume Next > >> > WSHNetwork.RemoveNetworkDrive sDrive > >> > Err.Clear > >> > WSHNetwork.MapNetworkDrive sDrive,sShare > >> > MSIE.Document.Write "<BR>Mapping " & sDrive & " > to " > >> & sShare > >> > If sHome = 1 Then > >> > HOME = sDrive > >> > End If > >> > If Err.Number <> 0 Then > >> > MSIE.Document.Write "<BR><FONT > >> COLOR=#FF6666>ERROR! Mapping > >> >network drive " & sDrive & " Reason: " & > Err.Description > >> & "</FONT>" > >> > NErr = 1 > >> > End if > >> >End Sub > >> >'***end script*** > >> >. > >.
|
Mon, 16 May 2005 11:51:37 GMT |
|
|
Page 1 of 2
|
[ 17 post ] |
|
Go to page:
[1]
[2] |
|