Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Logon script over VPN connection

Status
Not open for further replies.

MRSOLO

Technical User
Jan 28, 2003
31
0
0
IE
I have set up a Win 2K RAS Server as a VPN server that authenticates Active Directory users via a Radius server, that connect via a wireless link It works fine from the viewpoint of successfully authenticating users and giving them network access. However when I try to run a logon script (vbs) to map drives and printers, the script runs under the username of the locally logged on user, not the authenticated active directory user. This basically means that the script fails to map the drives as the locally logged on user does not have the permissions to access the network drives in questions. Is there a way that I can force the script to run under the active directory account or is there a way that I can edit the script to prompt the user to enter his/her username and password.

The only way that I have got the logon script to run over the VPN is to log on to the PC initially with the cached credentials of the active directory user account and then log onto the VPN server with the same active directory user details. then but only then can I run the logon script successfully. this method is impractical for what we need to do though as essentially we are trying to setup a wireless network where users connect via VPN using their own laptops and we dont want to have to join these laptops to the domain at any stage.

Appreciate any assistance
 
You may look at the Runas command..., but I do have some doubts that it will sole your problem.

What's the consern about joining those computers to the domain? I can't really see any big security issues, after all that's what rest of the world is doing.

If you join the computers to the domain, you don't have to logon with cached credentials. You can define logon to domain through vpn. I would actually consider it a bigger security issue if the computers ain't a domain member, due to the fact that you can't use GPO.
 
Without joining the computers to your domain this really can not be accomplished as far as I can tell. After all, what you are saying is;

A. My computer isn't in the trusted list but go ahead and give me access to trusted information

B. I don't belong to your domain but go ahead and configure my PC anyway.

Either way you look at it, this should never be allowed or it would be a hackers dream come true.

I hope you find this post helpful.

Regards,

Mark
 
i found this a while ago but cant get it work on my machine, hmm i wonder why i am bothering posting it then!!

strDomain = "MyDomain"
Set objLogon = CreateObject("PassDlg.LogonDialog")
objLogon.ShowDialog "Enter Username and Password"
objlogon.AllowBlankUsername = False
objLogon.AllowBlankPassword = False
objCancelled = objLogon.Canceled
strUserName = objLogon.Username
strPassword = objLogon.Password
If objCancelled Then
WScript.quit
End If
 
Hello
I eventually got a way to get this working, which was simple in its execution, because the logon script and drive mapping kept looking at the local username that logged on instead of the active directory user who authenticated over VPN. The scripts wouldn't run as they didnt have permissions.
Now instead of using an initial local username, when I log on to the PC, I make the initial logon (CTRL ALT DEL) to the PC using a dial up connection to the VPN server with the domain user account. It authenticates, the PC sees only one user account (the domain one) and the scripts run fine.
Thanks
 
Thanks for the update. Glad you got it working.

I hope you find this post helpful.

Regards,

Mark
 
This seems to work as well.

I bundled this in to a EXE with Wscript and RunAs using GCBundler (Google it) and stuck it in the startup folder.

when run it runs as a hidden process monitering for IP changes to the NIC (such as a NIC being leased an IP by a DHCP server over a VPN/RAS connection) and locates and runs the logon script.

I have added the whole script here, it is rather large, but the guy that did it needs recognition for it :)

-----------------------

'////////////////////////////////////////////////////////////////////
'/
'/ Name: vpnraslogonhook.vbs
'/ Author: Darwin Sanoy
'/ Updates: '/ Bug Reports &
' Enhancement Req: Darwin@DesktopEngineer.com
'/
'/ Built/Tested On: Windows XP Beta 2
'/ Windows 2000, SP2
'/ Windows 95 OSR2, WMI 1.5, WSH 5.1
'/ Requires: OS: Any
'/ APIs: WMI
'/
'/ Main Function: Ensures that the logon script can run when computers
'/ connect to the network via VPN, RAS or dynamic IP
'/ configuration (plugging in after bootup - W2K and later)
'/
'/ Syntax: all variables configured in the script
'/
'/ Usage and Notes: See HTML documentation
'/
'/ Assumptions &
'/ Limitations: *) Blindly maps and unmaps drive to be used for logon script
'/
'/ Documentation: '/
'/ License: GNU General Public License see "license.txt" or
'/ '/
'/ Version: 3.0
'/
'/ Revision History:
'/
'/ 09/18/03 - 3.0 Functionality:
'/ - allow script to check all connection objects upon startup - this should handle
'/ the case where folks authenticate using RAS - must use file/folder pre-emption
'/ check to prevent multiple logon script runs when logging on through a direct
'/ hardwire connection.
'/ - added utility script dumpconnections.vbs to help identify which IP addresses
'/ are changing when connecting with RAS, VPN, etc.
'/ Bug Fixes and Other Changes:
'/ - program would crash on cached DHCP information - ip address may have been an empty string
'/ - new setup program that creates shortcuts and has an uninstall add/remove programs item
'/ - structure changes and sample code segments to ease ability to customize
'/ - documentation enhanced with usage scenarios and dumpconnection.vbs information
'/ 03/21/02 - 2.9 Functionality:
'/ - preemption of logon script run based on file or folder existence
'/ - added some commented sample code to demo usage of multiple subnet lists
'/ Bug Fixes and Other Changes:
'/ - fixed bug with service startup that prevented services from starting
'/ - Additional trace logging for better problem diagnosis.
'/ - Code reorganization - easier to customize
'/ - Performance improvements
'/ 03/14/02 - 2.8 Functionality:
'/ - preemption of logon script run based on running processes - generally for detecting
'/ if a mail agent (such as mapis32.exe) triggered a dial-up session
'/ - addition of variable dump to the VERBOSEMSG tracing mode
'/ Bug Fixes and Other Changes:
'/ - Fix for failure of script upon deletion of a network connection
'/ - Fix for virtual devices that do not have IP addresses or have 0.0.0.0 addresses
'/ - removal of "runonce" support - did not behave as expected in specific situations
'/ 09/26/01 - 2.4 - Support for classless subnet address matching
'/ - Removed Win32_IP4RouteTable support due to classless subnet matching
'/ - Script now monitors __InstanceOperationEvent to capture all connection
'/ types with a single script
'/ - Selective service startup
'/ - Tracing / Error / Logging routine
'/ - Simplified script to use graceful failover of logon script failure
'/ 06/29/01 - 1.5 - Adapted to work with .BAT/.CMD logon scripts
'/ - Validates variable type of address to check
'/ - error reporting possible for not being able to execute the logon script
'/ - consolidated route and VPN/RAS/DYNAMIC script into one
'/ - added wait time for slow connection processes
'/ 06/13/01 - 1.2 - improved matching logic to only match beginning of IP
'/ address - suggested by Michael Niehaus (djs)
'/ 06/09/01 - 1.1 - inital version (djs)
'/
'////////////////////////////////////////////////////////////////////

'////////////////////////////////////////////////////////////////////
' Setup for Subnet Matching
'////////////////////////////////////////////////////////////////////

aSubnetList = Array("192.168.2.0/255.255.255.0")
' This is a list of the subnets that you wish to have the script check for matches.
' Place most frequent matches (including supernets) first in the list.

' The next line shows that the script could be customized to use multiple
' subnet lists. Perhaps you want a different logon script based on whether
' VPN, RAS or hardwire is being accessed. Or perhaps a different logon script
' based on which physical site (list of subnets) is being connected to.
' search for bSubnetMatch to see where this would be used later in the script.
'aSubnetListSecondarySample = Array("192.168.123.0/255.255.255.0")

bAllMatches = False
' If bAllMatches is set to true the SubnetMatch routine will search the entire
' list for every match. If it is set to false, the routine returns after the
' first match.

'//////////////////////////////////////////////////////////////////////
' Setup for Script Run behavior
'//////////////////////////////////////////////////////////////////////

sWaitTime = 1

'wait time in seconds - just in case complete connection takes a while after
'initial ip address detection occurs, do not set to blank.

'//////////////////////////////////////////////////////////////////////
' Setup for calling logon script from a drive letter
'//////////////////////////////////////////////////////////////////////

sLogonScriptShare = "\\Obiwan\netlogon"
sLogonScriptDrive = "Z:" 'no trailing slash!
sLogonScriptPath = "" 'no trailing or leading slash!
sLogonScriptName = "LOGIN.BAT" 'include extension!
' The above values govern connecting to the share to execute the logon script
' If the logon script can be executed exclusively using UNCs, these variables
' and the code that uses them can be simplified - see the documentation for
' details.

'//////////////////////////////////////////////////////////////////////
' Setup for Selective Service Startup
'//////////////////////////////////////////////////////////////////////

bStartServices = False
' This is set to true if the script should attempt to start the services in
' list aServiceStartList

aServiceStartList = Array("scheduler")
' An array holding each service that should be started upon a successful
' network connection

'//////////////////////////////////////////////////////////////////////
' Setup for Pre-empting if Mail Agent Triggered Connection
'//////////////////////////////////////////////////////////////////////

bPreemptIfProcessRunning = False
' This is set to true if the logon script should NOT be processed if
' a mail agent triggered this connection

bAllProcesses = False
' Determines whether all EXEs listed in the array aProcessRunningList
' must be running in order to preempt logon script execution.

aRunningProcessEXEList = Array("svchost.exe")
' An array holding the name of the running EXE to check for to determine
' whether the mail agent is running.

'//////////////////////////////////////////////////////////////////////
' Setup for Pre-empting if a file or folder exists
'//////////////////////////////////////////////////////////////////////
' Used to determine if logon script has already successfully run since
' the last matched connection event. This is primarily used to prevent
' unnecessary running of the logon script when network connections
' renew their configuration without a real configuration event.
' Some VPN adapters make changes to the configuration after the initial
' connection, causing the logon script to run again. IPCONFIG /renew
' will also cause this behavior.
' The paths used here should not be a UNC because a UNC will
' exist regardless of whether the logon script has run.
' if both values are set to "", no file/folder existence checking is performed.

sFilepath = ""
' file to check for existence - should not be a UNC path
' leave blank for no checking

sFolderpath = ""
' folder to check for existence - should not be a UNC path
' leave blank for no checking

bCheckOnFirstRun = True
' check if logon script needs to be run when vpnraslogon hook first starts
' this must be used in conjunction with above pre-empting when a file or
' folder exists or else your logon script will run two ore more times when
' users connect via ethernet. You logon script should also be set to run
' before the useris allowed access to the desktop if you are using the
' Startup group to trigger this script.

'//////////////////////////////////////////////////////////////////////
' Setup for Tracing, Logging and Error Reporting
'//////////////////////////////////////////////////////////////////////


' Constants for tracing routine. Can be used in TraceLevel and individual
' messages
Const VERBOSEMSG = 5
Const INFOMSG = 10
Const ERRORMSG = 30
Const NOMSG = 100

Dim FileSetup, oLogFileObject
' The above variables need to be global

sTraceLevel = INFOMSG
' Trace level can be set to any numeric value. It determines the threshold at
' which a message will be displayed. It can also be set by retrieving an
' environment variable (must customize this script) so that tracing can be
' controled without recompiling.

msgAction = "INTERACTIVE"
' msgAction has the following possible values:
' INTERACTIVE - all error and tracing messages are displayed interactively
' LOG - all error messages are logged to a file
' BOTH - all error messages are displayed and logged
' NONE - do not generate any messages - it is better to set sTraceLevel
' to 100 (or constant NOMSG)

sLogFileName = "vpnraslogonhook.log"
' Log file name to be used. If this is left blank a random log name is choosen.
' all log files are stored in the directory specified by the TMP variable

bLogFileOverwrite = True
' If set to false, the same log file is used repeatedly to give complete logging
' of every time this program runs. This setting only makes sense if you give
' a literal log name in sLogFileName - otherwise a random log file name is
' generated with each execution

Traceandlog VERBOSEMSG, "Trace Messaging Started at: ", Date & " " & Time

If sTraceLevel <= VERBOSEMSG Then
VariableDump
End If

'//////////////////////////////////////////////////////////////////////
' Main script code
'//////////////////////////////////////////////////////////////////////

Dim oShell : Set oShell = createobject("wscript.shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")

'If setup, check all existing connections when the script first starts (handle authentication through RAS)
If bCheckOnFirstRun Then
For each Config in GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("Win32_NetworkAdapterConfiguration")

If VarType(Config.Ipaddress(0)) = 8 Then
If Config.Ipaddress(0) <> "0.0.0.0" and InStr(1,config.ipaddress(0),".",1) Then
ProcessConnection(Config)
Else
Traceandlog INFOMSG, "Zero IP Address", "Zero's or blank ip address - must have caught a connection in transition between states: " & Config.Caption
End If

Else
Traceandlog INFOMSG, "Invalid IP Address", "The connection does not have a valid ip address: " & Config.Caption
End If
Next

End If

'setup event monitoring
Set Events = GetObject("winmgmts:\\.\root\cimv2").ExecNotificationQuery ("SELECT TargetInstance.Name FROM __InstanceOperationEvent WITHIN 4 WHERE TargetInstance ISA 'Win32_NetworkAdapterConfiguration'")

Do

Set oConnectEvent = Events.nextevent

WScript.Sleep(1000 * sWaitTime)

Set ConnectObject = oConnectEvent.TargetInstance

If VarType(oConnectEvent.TargetInstance.Ipaddress(0)) = 8 Then
' this must be done as two if statements so that checking for "0.0.0.0" does not crash when there is no ipaddress (empty array)
If oConnectEvent.TargetInstance.Ipaddress(0) <> "0.0.0.0" and InStr(1,ConnectObject.Ipaddress(0), ".",1) Then
ProcessConnection(ConnectObject)
Else
Traceandlog INFOMSG, "Zero IP Address", "Zero's or blank ip address - must have caught a connection in transition between states: " & ConnectObject.Caption
End If

Else
Traceandlog INFOMSG, "ConnectionDeleteorNoIPAddress", "The connection event was a deletion or an invalid ip address was returned: " & ConnectObject.Caption
End If
Loop

Sub ProcessConnection(ConnectInstance)
'ConnectInstance is a collection of Win32_NetworkAdapterConfiguration Instances
'//////////////////////////////////////////////////////////////////////
' Check for subnet match
'//////////////////////////////////////////////////////////////////////
'[OVERALLPREEMPTIONLOGIC]
If SubnetMatch(aSubnetList, ConnectInstance.IPAddress(0), bAllMatches, aListofMatches) Then

Traceandlog INFOMSG, "Matching Subnet", "Matches: " & UBound(aListofMatches) + 1 & vbnewline & "First Match (for " _
& ConnectInstance.IPAddress(0) & ") :" & aListofMatches(0)

Else
'No match found
Traceandlog INFOMSG, "Checking Adapter Config", "No Match Found For: " & ConnectInstance.Caption & " with IP Address: " & ConnectInstance.IPAddress(0)
Exit Sub
End If

'//////////////////////////////////////////////////////////////////////
' INSERT Branching logic for logon script actions based on subnet and/or other connection attributes
'//////////////////////////////////////////////////////////////////////
'[BRANCHINGLOGIC]

' Please see the documentation for all the parameters that can be used here.

' Use dumpconnections.vbs (included with this script) to ensure that your criteria are valid.

' This example shows that we can only reliably detect our company logons by also checking the DNS domain of the connection. Maybe employees regularly
' connect to another network with the same private addressing scheme as your network and would need further refinement to be sure. This would likely be
' as the main check up above.
'If SubnetMatch(aSubnetListSecondarySample, ConnectInstance.IPAddress(0), bAllMatches, aListofMatches) and ConnectInstance.DNSDomain = "acme.com" Then
' Traceandlog INFOMSG, "Matching Subnet", "Matches: " & UBound(aListofMatches) + 1 & vbnewline & "First Match (for " _
' & ConnectInstance.IPAddress(0) & ") :" & aListofMatches(0)
'Else
' Exit Sub
'End If

'This example prevents processing of VMWare Virtual Adapters
'If SubnetMatch(aSubnetListSecondarySample, ConnectInstance.IPAddress(0), bAllMatches, aListofMatches) and ConnectInstance.ServiceName <> "VMnetAdapter" Then
' Traceandlog INFOMSG, "Matching Subnet", "Matches: " & UBound(aListofMatches) + 1 & vbnewline & "First Match (for " _
' & ConnectInstance.IPAddress(0) & ") :" & aListofMatches(0)
'Else
' Traceandlog INFOMSG, "Checking Adapter Config", "VMWare Adapter Skipped"
' Exit Sub
'End If

' The following shows that based on a subnet match AND a SPECIFIC DHCP server we can isolate all computers logging on in AsiaPacific
'If SubnetMatch(aSubnetListSecondarySample, ConnectInstance.IPAddress(0), bAllMatches, aListofMatches) and ConnectInstance.DHCPServer = "192.168.71.71" Then
' DO SOME STUFF FOR AsiaPacific Logons
'End If

' The following shows that based on a subnet match AND a DHCP server in a specific list
'If SubnetMatch(aSubnetListSecondarySample, ConnectInstance.IPAddress(0), bAllMatches, aListofMatches) and inStr(ConnectInstance.DHCPServer,"192.168.71.71|192.168.45.32|192.168.65.45" Then
' DO SOME STUFF FOR AsiaPacific Logons
'End If

'//////////////////////////////////////////////////////////////////////
' Check if file or folder exists to preempt (logon script has already run)
'//////////////////////////////////////////////////////////////////////

bPreemptObjectExists = False
If sFilepath <> "" or sFolderpath <> "" Then
bPreemptObjectExists = checkobjectexist(sFilepath, sFolderpath)
End If

If bPreemptObjectExists Then
Exit Sub
End If

'//////////////////////////////////////////////////////////////////////
' Check if process(es) are running to preempt (mail agent or other initiated connection)
'//////////////////////////////////////////////////////////////////////

iNumberProcessesRunning = 0
If bPreemptIfProcessRunning Then
bPreemptDueToRunningProcesses = CheckRunningProcesses(aRunningProcessEXEList, bAllProcesses)
End If

If bPreemptDueToRunningProcesses Then
Traceandlog INFOMSG, "Run Logon Script", "Preempting Due to one or more Identified Processes Running"
Exit Sub
End If

'//////////////////////////////////////////////////////////////////////
' Everything looks good - attempt the logon script
'//////////////////////////////////////////////////////////////////////

Set oNet = CreateObject("Wscript.Network")

Traceandlog INFOMSG, "Main Routine", "Attempting to execute: " & sLogonScriptDrive & "\" & sLogonScriptPath & "\" & sLogonScriptName

On Error Resume Next
oNet.RemoveNetworkDrive sLogonScriptdrive, True, True
Traceandlog INFOMSG, "Unmapping Drive", "Error 0x" & CStr(Hex(Err.Number)) & err.description
Err.clear

oNet.MapNetworkDrive sLogonScriptdrive, sLogonScriptShare
Traceandlog ERRORMSG, "Mapping Drive", "Error 0x" & CStr(Hex(Err.Number)) & err.description
Err.clear

RunCmd = oShell.Run(sLogonScriptDrive & "\" & sLogonScriptPath & "\" & sLogonScriptName, 1, True)
If err.number Then
'Error handling code goes here
'Script was not found, drive was not mapped or no security access
Traceandlog ERRORMSG, "Running Logon script", "Error 0x" & CStr(Hex(Err.Number)) & err.description
End If
Err.clear

oNet.RemoveNetworkDrive sLogonScriptdrive, True, True
Traceandlog INFOMSG, "Unmapping Drive (second time)", "Error 0x" & CStr(Hex(Err.Number)) & err.description
Err.clear

On Error GoTo 0

If bStartServices Then
If UBound(aServiceStartList) >= 0 Then
For each sServiceName in aServiceStartList
startservice sServiceName
Next
End If
End If

End Sub

Private Function SubnetMatch(aSubnetsToMatch, IPAddress, bAllMatches, aMatchList)
For each subnetpair in aSubnetsToMatch
pair = split(subnetpair, "/", 2)
subnetoctets = split(pair(1), ".", 4)
ipaddroctets = split(IPAddress, ".", 4)

If pair(0) = join(Array(ipaddroctets(0) and subnetoctets(0), ipaddroctets(1) and subnetoctets(1), _
ipaddroctets(2) and subnetoctets(2), ipaddroctets(3) and subnetoctets(3)),".") Then

SubnetMatch = True
If MatchList = "" Then
MatchList = MatchList & subnetpair
Else
MatchList = MatchList & ", " & subnetpair
End If

If not bAllMatches Then
aMatchList = Array(subnetpair)
Exit For
End If

End If
Next

If SubnetMatch Then
aMatchList = split(matchlist, ",")
End If

End Function

Private Function CheckObjectExist(sFileToCheck, sFolderToCheck)
Traceandlog INFOMSG, "CheckObjectExists", "Object Existence Checking Requested, check existence"
If (fso.FileExists(sFileToCheck)) Then
CheckObjectExist = True
Traceandlog INFOMSG, "FileExistCheck", sFileToCheck & " File Exists indicating logon script has already run, logon script will not run again"
Else
Traceandlog INFOMSG, "FileExistCheck", sFileToCheck & " File DOES NOT Exist"
End If
If (fso.FolderExists(sFolderToCheck)) Then
CheckObjectExist = True
Traceandlog INFOMSG, "FolderExistCheck", sFolderToCheck & " Folder Exists indicating logon script has already run, logon script will not run again"
Else
Traceandlog INFOMSG, "FolderExistCheck", sFolderToCheck & " DOES NOT Exist"
End If
End Function

Private Function CheckRunningProcesses(aRunningProcessEXEListf, bAllProcessesf)
If UBound(aRunningProcessEXEListf) >= 0 Then
Traceandlog INFOMSG, "Prempt If Process Running", "Preempting if process is running (bPreemptIfProcessRunning=True) is true, checking running process list"
For each sRunningProcessEXE in aRunningProcessEXEListf
Set objInstance = GetObject("winmgmts:\\.\root\cimv2").ExecQuery ("select * from win32_process where name = '" & sRunningProcessEXE & "'")
If objInstance.count > 0 Then
iNumberProcessesRunning = iNumberProcessesRunning + 1
Traceandlog INFOMSG, "Process Running", objInstance.count & " instances of " & sRunningProcessEXE & " Running"
End If
Next
End If
If bAllProcessesf = True Then
If iNumberProcessesRunning = UBound(aRunningProcessEXEListf) + 1 Then
CheckRunningProcesses = True
Traceandlog INFOMSG, "All Processes", "All Processes must be running to preempt (bAllProcesses=True) - ALL processes were running, logon script will preempt"
Else
Traceandlog INFOMSG, "All Processes", "All Processes must be running to preempt (bAllProcesses=True) - NOT ALL processes were running, logon script will run"
End If
Else
Traceandlog INFOMSG, "Any Process", "Any process can be running to preempt (bAllProcesses=False), checking if any were running"
If iNumberProcessesRunning > 0 Then
Traceandlog INFOMSG, "At Least One", "At least one process was running - logon script will preempt"
CheckRunningProcesses = True
Else
Traceandlog INFOMSG, "Any Processes", "At least one process must be running, but none were, logon script will run"
End If
End If

End Function

Sub startservice(strServiceName)
' Can be removed if no services will be started as part of this script
On Error Resume Next
Set objInstance = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_Service='" & strServiceName & "'")
If Err.Number Then
Traceandlog ERRORMSG, "Open Service Object", "Error 0x" & CStr(Hex(Err.Number)) & _
" occurred in getting service " & strServiceName & "."
Err.Clear
Exit Sub
End If
If objInstance is nothing Then
Exit Sub
Else
intStatus = objInstance.StartService()
If intStatus = 0 Then
Traceandlog INFOMSG, "Start Service", StrServiceName & " started service"
ElseIf intStatus = 10 Then
Traceandlog INFOMSG, "Start Service", StrServiceName & " Service Already Started"
ElseIf intStatus = 14 Then
Traceandlog INFOMSG, "Start Service", StrServiceName & " Service Is Set to Disabled"
Else
Traceandlog ERRORMSG, "Start Service", StrServiceName & " Unable to start service"
End If
End If
On Error GoTo 0
End Sub

Sub TraceandLog(nLevel, sCodeLocation, sText)

if sTraceLevel <= nLevel Then

LogLine = Now & " Message Occurred in: " & sCodeLocation & _
vbNewline & " Severity: " & nLevel & _
vbNewline & " Message: " & sText

If msgAction = "INTERACTIVE" or msgAction = "BOTH" Then
wscript.echo LogLine
End If

If msgAction = "LOG" or msgAction = "BOTH" Then
If FileSetup <> True Then
SetupFileLogging sLogFileName
End If
oLogFileObject.writeline LogLine
End If
End If
End Sub


Sub VariableDump

Traceandlog VERBOSEMSG, "Variable Dump", "Dumping all variables:"

Traceandlog VERBOSEMSG, "bAllMatches", "bAllMatches = " & bAllMatches
If UBound(aSubnetList) >= 0 Then
For each sSubnetPair in aSubnetList
Traceandlog VERBOSEMSG, "sSubnetPair", "sSubnetPair = " & sSubnetPair
Next
End If

Traceandlog VERBOSEMSG, "sWaitTime", sWaitTime

Traceandlog VERBOSEMSG, "sLogonScriptShare", "sLogonScriptShare = " & sLogonScriptShare
Traceandlog VERBOSEMSG, "sLogonScriptDrive", "sLogonScriptDrive = " & sLogonScriptDrive
Traceandlog VERBOSEMSG, "sLogonScriptPath", "sLogonScriptPath = " & sLogonScriptPath
Traceandlog VERBOSEMSG, "sLogonScriptName", "sLogonScriptName = " & sLogonScriptName
Traceandlog VERBOSEMSG, "bUseNetworkLogonScript", "bUseNetworkLogonScript = " & bUseNetworkLogonScript

Traceandlog VERBOSEMSG, "bStartServices", "bAllMatches = " & bStartServices
If UBound(aServiceStartList) >= 0 Then
For each sServiceName in aServiceStartList
Traceandlog VERBOSEMSG, "aStartServicesList", "sServiceName = " & sServiceName
Next
End If

Traceandlog VERBOSEMSG, "bPreemptIfProcessRunning", "bPreemptIfProcessRunning = " & bPreemptIfProcessRunning
Traceandlog VERBOSEMSG, "bAllProcesses", "bAllProcesses = " & bAllProcesses
If UBound(aRunningProcessEXEList) >= 0 Then
For each sRunningProcess in aRunningProcessEXEList
Traceandlog VERBOSEMSG, "aStartServicesList", "sRunningProcess = " & sRunningProcess
Next
End If

Traceandlog VERBOSEMSG, "sFolderpath", "sFolderpath = " & sFolderpath
Traceandlog VERBOSEMSG, "sFilepath", "sFilepath = " & sFilepath

Traceandlog VERBOSEMSG, "sTraceLevel", "sTraceLevel = " & sTraceLevel
Traceandlog VERBOSEMSG, "msgAction", "msgAction = " & msgAction
Traceandlog VERBOSEMSG, "sLogFileName", "sLogFileName = " & sLogFileName
Traceandlog VERBOSEMSG, "bLogFileOverwrite", "bLogFileOverwrite = " & bLogFileOverwrite
End Sub

Sub SetupFileLogging(sFilename)
' Could be removed if file logging will never be used
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTempFolder = oFSO.GetSpecialFolder(2)

If sFilename <> "" Then
sTempName = oFSO.GetFileName(sFilename)
sLogFileName = sTempFolder & "\" & sTempName
Else
'Generate random name
sTempName = oFSO.GetFileName(oFSO.GetTempName)
sLogFileName = sTempFolder & "\" & lcase(left(sTempName, InstrRev(sTempName,".")-1)) & ".log"
End If

If oFSO.FileExists(sLogFileName) and not bLogFileOverwrite Then
Set oLogFileObject = oFSO.OpenTextFile(sLogFileName, 8, False)
Else
Set oLogFileObject = oFSO.OpenTextFile(sLogFileName, 2, True)
End If

oLogFileObject.writeline Now & " Logging Started"

FileSetup = True

End Sub

-----------------



Gurner

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top