chalkwellstu Posted January 29, 2008 Report Posted January 29, 2008 Hi all, anyone know where i can get a definitive list of all the scripting commands? or tell me how i write .... if strusername = abc then filename = xyz thanks
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 Hi all, anyone know where i can get a definitive list of all the scripting commands? or tell me how i write .... if strusername = abc then filename = xyz thanks are you wanting the script to write a text file and name it with xyz??? In vbscript for the username side : Set WshNetwork = WScript.CreateObject("WScript.Network") Dim strUser strUser = WshNetwork.UserName If strUse="Persons_UserName" Then file = "xyz" '<-- put your code here for the file name End If
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 are you wanting the script to write a text file and name it with xyz??? In vbscript for the username side : Set WshNetwork = WScript.CreateObject("WScript.Network") Dim strUser strUser = WshNetwork.UserName If strUse="Persons_UserName" Then file = "xyz" '<-- put your code here for the file name End If thanks Gecko thats the sort of thing i am looking for. i am basically writing a logoff script and want to split the results between staff and student.
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 how are you determining if they are a staff member or student member via there username ? also what results do you want outputting to this text file and where do you want it stored and what are you going to call this log file ?
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 how are you determining if they are a staff member or student member via there username ? also what results do you want outputting to this text file and where do you want it stored and what are you going to call this log file ? i am playing with a script i got from this forum to write internet history to an htm file. i am trying to teach myself script by making alterations to the program. at present the script dumpsd all output into one folder on the server. i want to split between staff and pupils so thought if i could determine staff(as there is less of them) i could default the rest as students.
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 where is the script so I can have a look at it and also need some way of determing staff from students....
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 where is the script so I can have a look at it and also need some way of determing staff from students.... i haven't started on the split stuff yet but feel free to have a look at this.Inetlog.zip
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 how are you going to determine from the username who is a member of staff and who is a student ? Am presuming your students have 04, 05, 06, 07 etc somewhere in there username and staff don't ? Or what exactly ?
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 not sure at the mo Gecko. all profile names are the student/staff names (legacy policy). as i am learning script as i go with this i am not aware of the all the posibles yet. first thoughts are .... if username = 'a' or 'b' or 'c' .... then goto staff else goto student then each nest would peform the functions dumping into staff or student depending on what it had found. as i said not quite sure how i am going to handle this yet ..... Stu
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 Need an example of a staff username and an example of a student username so we can decipher some obvious differences between the 2 types of usernames
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 Need an example of a staff username and an example of a student username so we can decipher some obvious differences between the 2 types of usernames ok, students profiles are both christian and surname together e.g. johnsmith staff profiles are just the christian name e.g. john thanks Gecko
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 ok, students profiles are both christian and surname together e.g. johnsmith staff profiles are just the christian name e.g. john thanks Gecko so aall staff user accounts only use there first name ( ie John ) for the username for logging in where as students have both the first name and last name ie johnsmith or markjones So to determine if it was a staff member we just need to match the firstname with the username ?
timzim Posted January 29, 2008 Report Posted January 29, 2008 Have a look at Kixtart - http://www.kixtart.org/ - you could use a Kixtart logoff script to distinguish between users on basis of AD groups. Might solve your problem?
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 yeah thats right Gecko, and thanks timzim i'll give that a look as well. Stu
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 (edited) Dim objUser, objComputer ComputerName = "server_name" '<<-- alter this to your servers name Set objComputer = GetObject("WinNT://" & ComputerName) For each objUser in objComputer wscript.echo objUser.name '<-- this line next in the above code where I have commented this line Is where you can change it from objUser.name to objUser.Description OR objUser.FullName as per the win32_UserAccount class : http://msdn2.microsoft.com/en-us/library/aa394507(VS.85).aspx If you could test that and give me a few examples back of each outcome ie what you get when you use fullname what you get when you use description etc so that I know if it is returning any useful info ie if it always returns the word student or staff in description If thats the case then that may be easier then trying to determine if there last name is outputted as a null string ie nothing to establish that its a staff member and if not then its a student. you need to alter the first line to the name of your server ie ComputerName = "MyServer" '<<-- alter this to your servers net bios name or i.p address Edited January 29, 2008 by gecko 1
chalkwellstu Posted January 29, 2008 Author Report Posted January 29, 2008 Dim objUser, objComputer ComputerName = "server_name" '<<-- alter this to your servers name Set objComputer = GetObject("WinNT://" & ComputerName) For each objUser in objComputer wscript.echo objUser.name '<-- this line next in the above code where I have commented this line Is where you can change it from objUser.name to objUser.Description OR objUser.FullName as per the win32_UserAccount class : http://msdn2.microsoft.com/en-us/library/aa394507(VS.85).aspx If you could test that and give me a few examples back of each outcome ie what you get when you use fullname what you get when you use description etc so that I know if it is returning any useful info ie if it always returns the word student or staff in description If thats the case then that may be easier then trying to determine if there last name is outputted as a null string ie nothing to establish that its a staff member and if not then its a student. you need to alter the first line to the name of your server ie ComputerName = "MyServer" '<<-- alter this to your servers net bios name or i.p address Hey thanks Gecko i really appreciate your time here, i'll insert this lot and see what i get. can you trace out a script into a txt file?
mac_shinobi Posted January 29, 2008 Report Posted January 29, 2008 (edited) yes you can output the data by using the fso : Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.CreateTextFile ("Users.txt", true) Dim objUser, objComputer ComputerName = "server_name" '<<-- alter this to your servers name Set objComputer = GetObject("WinNT://" & ComputerName) For each objUser in objComputer ts.Write objUser.name & vbcrlf '<-- this line next That way it creates a text file called users in the same place where your script is located, so when you have objUser.name, run the script, it will create the text file, hopefully with first_name second_name third_name etc then copy that text file and call it name.txt then change that one line to objUser.FullName and repeat so that you change the name of the file so it does not over write it and then change the line in the script again to objUser.Description Then post all 3 text files ( assuming that the output into the text file is as per above with one name on each line ) Then I can download them and have a look and finish the script off. You are probably better off taking a few examples from each and pm'ing me with those and put comments in so I know which examples are students and which ones are staff members. Edited January 29, 2008 by gecko
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now