Re: VB Script Error
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 15 Jun 2006 11:35:20 -0500
Hi,
You can bind to AD objects with alternate credentials, but this does not
allow access to file system objects. The only solution I can think of that
might work is the SWbemLocator object in WMI, which allows authentication to
remote systems with alternate credentials. Of course, the username/password
are hard coded in the script, so that is a security concern. The
SWbemLocator object is described in this link, with an example program:
http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_ciga.mspx
Using WMI to copy files is documented here:
http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_mrse.mspx
If you are not familiar with WMI, you might want to browse other topics in
the TOC to the left in these pages. Also, there would be much less security
risk if you created an AD group, gave the group the required permissions,
then made the appropriate users (perhaps the group "Domain Users") members
of this group.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"Curtis Rich" <CurtisRich@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4B7687A8-27F0-487D-9313-8463313BAD1D@xxxxxxxxxxxxxxxx
Is there a way I can have the script run as a domain admin? Such as the
runas command/parameter?
"Richard Mueller" wrote:
No, logon scripts run with the permissions of the user in the domain (and
System privileges on the local computer).
You can run the script after you have logged in. If it works when you are
logged in as Domain Admin, but not as a regular user, then the problem is
permissions. You may need to grant Domain Users permissions.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"Curtis Rich" <CurtisRich@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1D0B735F-AF96-4993-8EDF-F998A392FB64@xxxxxxxxxxxxxxxx
When I run this through group policy as a user script, I get an error
at
line
80 Char 3..... Permission Denied. Can anyone explain what may be
happening.... the script is trying to write a license file and .dll to
a
Lotus Notes directory, but shouldn't any logon script be performed
through
Domain Administrator privileges?
Here is a copy of the script.......
Option Explicit
Const EVENT_TYPE_SXS = 0
Const EVENT_TYPE_ERR = 1
Const EVENT_TYPE_WRN = 2
Const EVENT_TYPE_INF = 4
Const REG_KEY = "HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes\Path"
Const REMOTE_PATH = "\\mydomain.com\share"
Const TARGET_DRV = "G:"
Const TARGET_DIR = "\Midas LSX\"
Dim objShell
Dim objNetwork
Dim objFileSys
Dim objFileInstalled
Dim objFileTarget
Dim strNotesPath
Dim strFileArray
Dim strFileName
'// CREATED:
'// 04/12/2006
'//
'// AUTHOR:
'// Developer
'//
'// DESCRIPTION:
'// This script is intended to be used as a login script. It checks
for
the
presence
'// of a license file and the dll file comprising the Midas LSX
(LotusScript
Extension)
'// for use in Lotus Notes client and server applications.
'// Create required WSH objects
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Call objShell.LogEvent(EVENT_TYPE_INF, "Attempting to verify Midas LSX
installation.")
'// Read the registry value for the Notes program directory
On Error Resume Next '// disable error reporting (e.g., if registry key
doesn't exist)
strNotesPath = objShell.RegRead(REG_KEY)
'// If Notes isn't installed, quit the script
If Len(strNotesPath) = 0 Then
MsgBox "Unable to read the following registry key:" & vbCr & vbTab &
REG_KEY & vbCr & "If this condition persists, please notify Networking
Support.", , "Unable to read registry key . . ."
Call objShell.LogEvent(EVENT_TYPE_ERR, "Login script - unable to read
the
following registry key: " & vbCr & REG_KEY)
Call WScript.Quit()
End If
'// Attempt to map network drive
On Error Resume Next '// disable error reporting (e.g., if drive is in
use)
Call objNetwork.MapNetworkDrive(TARGET_DRV, REMOTE_PATH)
'// Re-enable error reporting
On Error GoTo 0
'// Create an array of the target file names
strFileArray = Array("licmidas.lic", "nlsxrtc.dll")
'// Initialize file objects to nothing
Set objFileInstalled = Nothing
Set objFileTarget = Nothing
'// Check the dates on the required files
For Each strFileName in strFileArray
Set objFileTarget = objFileSys.GetFile(TARGET_DRV & TARGET_DIR &
strFileName)
On Error Resume Next '// disable error reporting (e.g., if file isn't
found)
Set objFileInstalled = objFileSys.GetFile(strNotesPath & strFileName)
On Error GoTo 0 '// Re-enable error reporting
'// If a version of the file exists, compare dates to determine if an
update is needed
If Not(objFileInstalled Is Nothing) Then
If objFileTarget.DateLastModified > objFileInstalled.DateLastModified
Then
'MsgBox "Target file " & objFileTarget.Path & " date modified: " &
objFileTarget.DateLastModified & vbCr & _
'"Installed file " & objFileInstalled.Path & " date modified: " &
objFileInstalled.DateLastModified, , "DEBUG . . ."
Call objFileTarget.Copy(objFileInstalled.Path, True)
Call objShell.LogEvent(EVENT_TYPE_INF, "File " & strFileName & "
updated
successfully . . .")
End If
Else '// If a version of the file doesn't exist, copy it to the
destination
directory.
Call objFileTarget.Copy(strNotesPath & strFileName, True)
Call objShell.LogEvent(EVENT_TYPE_INF, "File " & strFileName & " added
successfully . . .")
End If
Set objFileInstalled = Nothing
Set objFileTarget = Nothing
Next
'// Dereference WSH objects
Set objShell = Nothing
Set objNetwork = Nothing
Set objFileSys = Nothing
'// Quit the script
Call WScript.Quit()
This script was developed by a programmer and he is certain his script
is
perfect. Any help would be greatly appreciated. Thanks
.
- Follow-Ups:
- Re: VB Script Error
- From: Michael Harris \(MVP\)
- Re: VB Script Error
- References:
- VB Script Error
- From: Curtis Rich
- Re: VB Script Error
- From: Richard Mueller
- Re: VB Script Error
- From: Curtis Rich
- VB Script Error
- Prev by Date: Re: about:blank and ie.readyState
- Next by Date: Re: about:blank and ie.readyState
- Previous by thread: Re: VB Script Error
- Next by thread: Re: VB Script Error
- Index(es):
Relevant Pages
|