Problems writing script which checks the users group and date

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2005
Posts: 15
Reputation: grc1uk is an unknown quantity at this point 
Solved Threads: 0
grc1uk grc1uk is offline Offline
Newbie Poster

Problems writing script which checks the users group and date

 
0
  #1
May 24th, 2005
Hello

I have not had much programming experience especially with VBS. I have been asked to write a script which checks what AD group a user is in and then runs a specific drive mappings for that group and user, also i need the script to check the date. This is needed so that (for example) on Friday when the user logs on they recieve additional drives or an application starts.

This is what i have so far............

  1. on error resume next
  2.  
  3. Dim WshNetwork, strUserName
  4.  
  5. Set WshNetwork = CreateObject("WScript.Network")
  6.  
  7. strUserName = wshnetwork.Username
  8.  
  9. wshnetwork.MapNetworkDrive "w:", "\\Server_name\Departments"
  10.  
  11. If IsMember(WshNetwork.username, "user_name") Then
  12.  
  13. wshnetwork.MapNetworkDrive "z:", "\\Server_name\departments\user_name"
  14. wshnetwork.MapNetworkDrive "I:", "\\Server_name\Another_folder"
  15. wshnetwork.MapNetworkDrive "O:", "\\Server_name\Another_folder"
  16. wshnetwork.MapNetworkDrive "P:", "\\Server_name\Another_folder"
  17. wshnetwork.MapNetworkDrive "V:", "\\Server_name\Another_folder"
  18.  
  19. End if
  20.  
  21. wscript.quit
.................................

This works fine for me (one person) what i need to get is instead of it just running for me i need it to check the group. Also i need to check the date so that if the date is, for example, Friday they get an app open when the user logs on.

I hope this makes some sence to someone as i think i lost myself while typing!!! :o

Any help would be appriciated

Thank you

Gareth Collins
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Problems writing script which checks the users group and date

 
0
  #2
May 24th, 2005
I'm not 100% sure what an AD Group is.... if you can give me a little more light on that subject, I can probably help you out. As for retrieving the Day of the Week (say, Sunday - Saturday), I have written a function that returns the day of the week from the current day. Here is that function, just stick it at the very very bottom of your script (like, after wscript.quit):

  1. public function ReturnDay
  2. RawDate = FormatDateTime(Now(), 1)
  3. Parts = split(RawDate, ",")
  4. ReturnDay = Parts(0)
  5. end function

And you can call that function like this:
  1. TheDay = ReturnDay()

You would probably use it like so:
  1. TheDay = ReturnDay()
  2.  
  3. if Theday = "Friday" then
  4. ' /* Do Stuff Here For Friday */
  5. else
  6. ' /* Do Stuff Here For Every Other Day */
  7. end if

If you can get me a little more info on "AD", I'll see what I can do about retrieving the Group that the user belongs to.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 15
Reputation: grc1uk is an unknown quantity at this point 
Solved Threads: 0
grc1uk grc1uk is offline Offline
Newbie Poster

Re: Problems writing script which checks the users group and date

 
0
  #3
May 24th, 2005
Thanks for the responce. AD = Active Directory, where in an organisation you put your users and groups. Hope that helps. I have found some code that might actually help me with this...

  1. Option Explicit
  2. Dim objNetwork, objUser, CurrentUser
  3. Dim strGroup
  4.  
  5. Const Admin_Group = "cn=oly_users_admin"
  6. Const Managers_Group = "cn=oly_users_manager"
  7. Const Accounting_Group = "oly_users_accounting"
  8. Const Estimate_Group = "cn=oly_users_estimate"
  9. Const Design_East_Group = "cn=oly_design_east"
  10. Const Design_West_Group = "cn=oly_design_west"
  11. Const All_Users_Group = "cn=oly_users_all"

Some thing along the line of the above is what i will need to write.

With regards to the posting that you made with the time, thanks.. I am still trying to get it working. What i am trying is to get it to display a simple .htm file every Tuesday to all people who will run the script when they log on to the computer.

So far this is the code i am using for this (mainly thanks to your post)...

  1. public function ReturnDay
  2. RawDate = FormatDateTime(Now(), 1)
  3. Parts = split(RawDate, ",")
  4. ReturnDay = Parts(0)
  5. end function
  6.  
  7. TheDay = ReturnDay()
  8.  
  9. if Theday = "Tuesday" then
  10.  
  11. shell ("C:\progra~1\intern~1\iexplore.exe file://cih_data\IT\Public\CIHStaffNews.htm")
  12.  
  13. else
  14.  
  15. end if
----------

Any ideas why this is not calling this .htm from a file shared network drive??

Thanks again for your help
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Problems writing script which checks the users group and date

 
0
  #4
May 24th, 2005
"file://cih_data\IT\Public\CIHStaffNews.htm"
You Have a mapped drive called cih_data?

  1. dim oIE
  2. Set oIE = WScript.CreateObject("InternetExplorer.Application")
  3.  
  4. TheDay = ReturnDay()
  5.  
  6.  
  7. if Theday = "Tuesday" then
  8. oIE.Navigate "file://cih_data\IT\Public\CIHStaffNews.htm"
  9. oIE.Show
  10. set oIE = nothing
  11. else
  12.  
  13. end if
  14.  
  15. WScript.Quit
  16.  
  17.  
  18. public function ReturnDay
  19. RawDate = FormatDateTime(Now(), 1)
  20. Parts = split(RawDate, ",")
  21. ReturnDay = Parts(0)
  22. end function
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Problems writing script which checks the users group and date

 
0
  #5
May 24th, 2005
And For Access Groups, it looks like you have it pretty well in play, but here is a link to a site that has a function and sample code for working with ADS with VBScript.
http://www.activexperts.com/activmon...mPrimGroup.htm
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 15
Reputation: grc1uk is an unknown quantity at this point 
Solved Threads: 0
grc1uk grc1uk is offline Offline
Newbie Poster

Re: Problems writing script which checks the users group and date

 
0
  #6
May 24th, 2005
Again, thank you.

The share is acutally the server name cih_data. I have tried that code but it still will not display that file, can you think of anyhthing i am doing wrong. I have basically copied your code from the preivous post

Thanks

Gareth
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Problems writing script which checks the users group and date

 
0
  #7
May 24th, 2005
Yes, I'm pretty sure that IE has no idea what that share is. If it was assigned a drive letter, that might be a different story... but because it's not, I'm willing to bet that IE has no clue what it's looking at. If you could assign the share a drive letter, it should probably work.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 15
Reputation: grc1uk is an unknown quantity at this point 
Solved Threads: 0
grc1uk grc1uk is offline Offline
Newbie Poster

Re: Problems writing script which checks the users group and date

 
0
  #8
May 24th, 2005
I have created a shared drive for this. G:

When trying this script...

  1. dim oIE
  2. Set oIE = WScript.CreateObject("InternetExplorer.Application")
  3.  
  4. TheDay = ReturnDay()
  5.  
  6.  
  7. if Theday = "Tuesday" then
  8. oIE.Navigate "file://G:\CIHStaffNews.htm"
  9. oIE.Show
  10. set oIE = nothing
  11. else
  12.  
  13. end if
  14.  
  15. WScript.Quit
  16.  
  17.  
  18. public function ReturnDay
  19. RawDate = FormatDateTime(Now(), 1)
  20. Parts = split(RawDate, ",")
  21. ReturnDay = Parts(0)
  22. end function
...................

I am still getting nothing displayed. If i copy the link G:\cihstaffnews.htm in to the RUN command it file opens. So i know that the link is correct...

any ideas??
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Problems writing script which checks the users group and date

 
0
  #9
May 24th, 2005
Oops. Just replace:
  1. oIE.Show

with:
  1. oIE.Visible = True
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 15
Reputation: grc1uk is an unknown quantity at this point 
Solved Threads: 0
grc1uk grc1uk is offline Offline
Newbie Poster

Re: Problems writing script which checks the users group and date

 
0
  #10
May 25th, 2005
I have changed the code but unfortunatly this is still not working. This is the code i have at present.

------------------
  1. dim oIE
  2. Set oIE = WScript.CreateObject("InternetExplorer.Application")
  3.  
  4. public function ReturnDay
  5. RawDate = FormatDateTime(Now(), 1)
  6. Parts = split(RawDate, ",")
  7. ReturnDay = Parts(0)
  8. end function
  9.  
  10. TheDay = ReturnDay()
  11.  
  12.  
  13. if Theday = "Wednesday" then
  14. oIE.Navigate "file://G:\CIHStaffNews.htm"
  15. oIE.Visible = True
  16. set oIE = nothing
  17. else
  18.  
  19. end if
  20.  
  21.  
  22. WScript.Quit
----------------------

Thanks again for your help on this
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC