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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translate Batch (.bat) into .vbs for use in Active Directory

Status
Not open for further replies.

TomKhawa

IS-IT--Management
Jun 20, 2003
1
FR
Hi,

In an Win2K domain with Active Directory, I want to monitor my users logins and logoffs.
I wrote these batch files:
1/
rem user logoff monitor

echo Logoff;%username%;date;time>>C:\_admin\FHP logs\sessions_monitor.txt

2/
rem user login monitor

echo Login;%username%;date;time>>C:\_admin\FHP logs\sessions_monitor.txt

I've set the group AD strategy so that users will all execute the script respectively when loging out and logging in. This does not work but I think this because Active Directory requires .vbs or.js scripts...

I have 2 options and need help for those:

A/ have a .vbs or a .js that will call my .bat
B/ translate the whole .bat into a .vbs or .js

Can you guys help me with this?

Thanks in advance

Tom
 
Well you'll need to use WSHScript to get the username,

So

Dim ForAppending = 4
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserName = WshNetwork.UserName

Set WshNetwork = Nothing

Set FSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = FSO.OpenTextFile(&quot;<PATH TO FILE>&quot;, ForAppending, True)

objLogFile.Writeline &quot;Login: &quot; & UserName & &quot;:&quot; & Now()

Set objLogFile = Nothing
Set FSO = Nothing


This should do it for you.
 
Hi TomKhawa,

I think you are making this to hard for youre self.
.bat is supported by Active directory, or lets say all files that the user can lanch, can be a login or logout script.

I think you have to check the permissions or policy again.

The most common problem is that you apply the policy to the computer OU, it shuld be on the user OU.
Check that you are using login/logout scripts for users, and not startup/shutdown scripts for computers.

// Wibbe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top