×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Get reports in AD from a VBS yes/no script

Get reports in AD from a VBS yes/no script

Get reports in AD from a VBS yes/no script

(OP)
Hello,

I need a VBS / HTA script to get a dialog box showing Yes/No options before logging into the system.

Users who select Yes should get their names reflected in a report and Users who select no should also get their names reflected in another report... These reports should be generated in Active Directory.

RE: Get reports in AD from a VBS yes/no script

Quote:


I need ...
Then show the code you've tried so far. This is a help forum, not a coding service...

RE: Get reports in AD from a VBS yes/no script

(OP)
x=msgbox ("Have you completed the tasks" ,4, "Press yes/no")

RE: Get reports in AD from a VBS yes/no script

(OP)
The users who give yes and no should get their names reflected in AD report... I m not a techie guy.. I need some scripts and procedure to proceed.. Please help me in this issue.

I have added this script in Group policy in logon script.. And i m getting the desired output... Just need to fetch the reports of the users who gave yes and no separately..

RE: Get reports in AD from a VBS yes/no script

And where is your problem ?
How to get the UserName or in the program logic ?

RE: Get reports in AD from a VBS yes/no script

(OP)
My problem is that i want to generate a report in AD... The report should have the user names who entered yes... and who entered no... How to do?

RE: Get reports in AD from a VBS yes/no script

I thought that you want to write reports into ordinary text files.
Don't know, how to generate reports in AD.

RE: Get reports in AD from a VBS yes/no script

(OP)
Its ok if i write reports in ordinary files also.... Can u help me in that issue? Is there any scripting line that i can add to copy the output in another file

RE: Get reports in AD from a VBS yes/no script

I thought, that it might look something like this:

report.vbs

CODE

' retrieve username from system variable
usrname = CreateObject( "WScript.Shell").ExpandEnvironmentStrings("%USERNAME%")
' retrieve username from network
'usrname = CreateObject("WScript.Network").UserName

result=msgbox ("Have you completed the tasks" , vbYesNoCancel, "Press yes/no")
select case result
  case vbYes
    'WScript.echo "You pressed YES"
    call write_report("report_YES.txt", usrname)
  case vbNo
    'WScript.echo "You pressed NO"
    call write_report("report_NO.txt", usrname)
  case vbCancel
    ' Do nothing
    'WScript.echo "You pressed CANCEL"
end select

sub write_report(reportname, username)
  'WScript.echo "Writing username='" & username & _
  '             "' into report ='" & reportname & "'"
  set fso = CreateObject("Scripting.FileSystemObject")
  const ForReading = 1, ForWriting = 2, ForAppending = 8
  ' open Report file
  set report_file = fso.OpenTextFile(reportname, ForAppending, True)
  ' line for writing into report
  report_line = username
  report_file.writeline(report_line)
  ' close Report file
  report_file.Close              
end sub 

If you want the user name from network then uncomment the appropriate line.
Or if you want to see how the program works uncomment the lines with WScript.echo ...
Change the path of files where they should be created

RE: Get reports in AD from a VBS yes/no script

(OP)
Thank you... U have solved my case

RE: Get reports in AD from a VBS yes/no script

You are welcome

RE: Get reports in AD from a VBS yes/no script

(OP)
1 small help... How to add date section in the script... Coz i need the username with the logon date

RE: Get reports in AD from a VBS yes/no script

quickly: to insert current date and time you can use

CODE

...
  ' get current date and time
  date_time = now
  ' line for writing into report
  report_line = username & " - " & date_time
  report_file.writeline(report_line)
... 
Unfortunately I do not know by heart how to determine logon date. It's not so simple - please Google for it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close