Running a script in Windows2000 Server
From: DanInTexas (DanInTexas_at_discussions.microsoft.com)
Date: 08/26/04
- Next message: Jeff Cochran: "Re: SP2 Blocking Script: Secret How-To-Run Info"
- Previous message: debra.dorn_at_navigant.com: "Scripting an OU to reverse Last Name, First Name to First Name Last Name"
- Next in thread: Jeff Cochran: "Re: Running a script in Windows2000 Server"
- Reply: Jeff Cochran: "Re: Running a script in Windows2000 Server"
- Reply: Jan: "Re: Running a script in Windows2000 Server"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Aug 2004 09:47:14 -0700
I am running Windows 2000 server from which this scrip t needs to be run. I
have client machines installed with Windows XP. I have a script file and a
database .mdb file in which I create all the user names.
I write a batch file and place it in all the client systems under group
policy/user configuration/windows settings/scripts/logon. Allong with the
batch file I write a shuttdown.exe file I am recieving a (Loading script
"\\cis236\storage\script\database.vbs" failed(The network path was not
found.).) error.
The script is below.
'This script can be used to limit who logs onto a computer in the lab.
'It compares the username of the current logged on user against a database and
'checks for matches. If no match is found the user is automatically logged
off
'after 2 seconds.
'Note that in order for this script to log users off you must place a copy of
'shutdown.exe from WindowsXP on every machine.
On Error Resume Next
dim conn, rs, strsql, username, dbline, flag, errdesc
flag = "n"
'the following 2 lines instanciate the connection and recordset object
'that will be used to connect to the database that houses the usernames
'to be checked against the environmental variable %username% which
'contains the username of the current logged on user.
Set conn = createobject("adodb.connection")
set rs = createobject("adodb.recordset")
'Instanciates an instance of the Windows Scripting Host Shell that
'is used to get access to environmental variables.
Set WshShell=Wscript.CreateObject ("WScript.Shell")
'Opens the connection object and specifies the path to the database with
'the CIS majors usernames. The path can be in the form of a local address:
'DBQ=c:\database.mdb or you can use an UNC path:
'DBQ=\\ServerName\ShareName\Filename.mdb if the database resides on a
central server.
conn.open "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=c:\students\students.mdb"
'errdesc = err.description
If Err.Number <> 0 Then
Wscript.quit
End If
'This is the SQL Select statement to pull usernames from the CISMAJORS table
'in the school.mdb database.
strsql = "select * from CISMAJORS"
'Sets the variable username equal to the environmental variable %username%.
username = WshShell.ExpandEnvironmentStrings("%Username%")
rs.open strsql, conn
'This Do While loop iterates through the recordset returned by the strsql
variable.
'The embedded If structure will set the variable flag to "y" if a match is
found
'in the returned recordset. If flag <> "y" after the loop is through then
the user
'will be logged off.
Do While NOT RS.EOF
dbline = rs(0)
If dbline = Ucase(username) Then
flag = "y"
End If
If dbline = Lcase(username) Then
flag = "y"
End if
rs.movenext
Loop
'Closes the connection and recordset objects and sets them to nothing.
rs.close
conn.close
set rs = nothing
set conn = nothing
'Creates instances of message and runprog which will be used to display
'a message and run a program respectively.
Set message = Wscript.CreateObject("Wscript.Shell")
Set runprog = Wscript.CreateObject("WScript.Shell")
'If a match is not found (flag = n) the following If test will display a
message
'and then call shutdown.exe to log the user off. This is done with the "-l"
switch.
'For further info on shutdown.exe open a command prompt and type "shutdown
/?".
If username = "Administrator" Then
flag = "y"
End if
If username = "db2admin" Then
flag = "y"
End if
If username = "temp" Then
flag = "y"
End if
If flag = "n" Then
display = message.popup("Only CIS Majors who are enrolled in upper division
classes" _
& vbNewLine & "and students enrolled in CIS course which requires Lab in
the course work" _
& vbNewLine & "are allowed use the lab. If above students cannot logon,
please send an" _
& vbNewLine & "email with your username to me at
aman@swt.edu.",10,"Administrator")
runprog.run ("shutdown.exe -l")
End If
If flag = "y" Then
display = message.popup("Lab Hours" _
& vbNewLine & "Mon-Fri : 8.00am to 9.00pm" _
& vbNewLine & "Please Email to aman@txstate.edu for any technical support." _
& vbNewLine & "Thank you," _
& vbNewLine & "Lab Admin",10,"Administrator")
End If
======================
Actually, we have a server running windows 2000server O.S. we have client
machines which has XP installed on it.
This script just makes some users to login to the systems and others not.
But we have some
problems running that script. what all we need to do inorder to runthat
script from the server machine.
=====================
- Next message: Jeff Cochran: "Re: SP2 Blocking Script: Secret How-To-Run Info"
- Previous message: debra.dorn_at_navigant.com: "Scripting an OU to reverse Last Name, First Name to First Name Last Name"
- Next in thread: Jeff Cochran: "Re: Running a script in Windows2000 Server"
- Reply: Jeff Cochran: "Re: Running a script in Windows2000 Server"
- Reply: Jan: "Re: Running a script in Windows2000 Server"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|