| | |
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:
Solved Threads: 0
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............
.................................
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
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............
VB.NET Syntax (Toggle Plain Text)
on error resume next Dim WshNetwork, strUserName Set WshNetwork = CreateObject("WScript.Network") strUserName = wshnetwork.Username wshnetwork.MapNetworkDrive "w:", "\\Server_name\Departments" If IsMember(WshNetwork.username, "user_name") Then wshnetwork.MapNetworkDrive "z:", "\\Server_name\departments\user_name" wshnetwork.MapNetworkDrive "I:", "\\Server_name\Another_folder" wshnetwork.MapNetworkDrive "O:", "\\Server_name\Another_folder" wshnetwork.MapNetworkDrive "P:", "\\Server_name\Another_folder" wshnetwork.MapNetworkDrive "V:", "\\Server_name\Another_folder" End if 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
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):
And you can call that function like this:
You would probably use it like so:
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.
VB.NET Syntax (Toggle Plain Text)
public function ReturnDay RawDate = FormatDateTime(Now(), 1) Parts = split(RawDate, ",") ReturnDay = Parts(0) end function
And you can call that function like this:
VB.NET Syntax (Toggle Plain Text)
TheDay = ReturnDay()
You would probably use it like so:
VB.NET Syntax (Toggle Plain Text)
TheDay = ReturnDay() if Theday = "Friday" then ' /* Do Stuff Here For Friday */ else ' /* Do Stuff Here For Every Other Day */ 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.
•
•
Join Date: May 2005
Posts: 15
Reputation:
Solved Threads: 0
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...
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)...
----------
Any ideas why this is not calling this .htm from a file shared network drive??
Thanks again for your help
VB.NET Syntax (Toggle Plain Text)
Option Explicit Dim objNetwork, objUser, CurrentUser Dim strGroup Const Admin_Group = "cn=oly_users_admin" Const Managers_Group = "cn=oly_users_manager" Const Accounting_Group = "oly_users_accounting" Const Estimate_Group = "cn=oly_users_estimate" Const Design_East_Group = "cn=oly_design_east" Const Design_West_Group = "cn=oly_design_west" 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)...
VB.NET Syntax (Toggle Plain Text)
public function ReturnDay RawDate = FormatDateTime(Now(), 1) Parts = split(RawDate, ",") ReturnDay = Parts(0) end function TheDay = ReturnDay() if Theday = "Tuesday" then shell ("C:\progra~1\intern~1\iexplore.exe file://cih_data\IT\Public\CIHStaffNews.htm") else end if
Any ideas why this is not calling this .htm from a file shared network drive??
Thanks again for your help
•
•
•
•
"file://cih_data\IT\Public\CIHStaffNews.htm"
VB.NET Syntax (Toggle Plain Text)
dim oIE Set oIE = WScript.CreateObject("InternetExplorer.Application") TheDay = ReturnDay() if Theday = "Tuesday" then oIE.Navigate "file://cih_data\IT\Public\CIHStaffNews.htm" oIE.Show set oIE = nothing else end if WScript.Quit public function ReturnDay RawDate = FormatDateTime(Now(), 1) Parts = split(RawDate, ",") ReturnDay = Parts(0) end function
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
http://www.activexperts.com/activmon...mPrimGroup.htm
•
•
Join Date: May 2005
Posts: 15
Reputation:
Solved Threads: 0
I have created a shared drive for this. G:
When trying this script...
...................
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??
When trying this script...
VB.NET Syntax (Toggle Plain Text)
dim oIE Set oIE = WScript.CreateObject("InternetExplorer.Application") TheDay = ReturnDay() if Theday = "Tuesday" then oIE.Navigate "file://G:\CIHStaffNews.htm" oIE.Show set oIE = nothing else end if WScript.Quit public function ReturnDay RawDate = FormatDateTime(Now(), 1) Parts = split(RawDate, ",") ReturnDay = Parts(0) 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??
Oops. Just replace:
with:
VB.NET Syntax (Toggle Plain Text)
oIE.Show
with:
VB.NET Syntax (Toggle Plain Text)
oIE.Visible = True
•
•
Join Date: May 2005
Posts: 15
Reputation:
Solved Threads: 0
I have changed the code but unfortunatly this is still not working. This is the code i have at present.
------------------
----------------------
Thanks again for your help on this
------------------
VB.NET Syntax (Toggle Plain Text)
dim oIE Set oIE = WScript.CreateObject("InternetExplorer.Application") public function ReturnDay RawDate = FormatDateTime(Now(), 1) Parts = split(RawDate, ",") ReturnDay = Parts(0) end function TheDay = ReturnDay() if Theday = "Wednesday" then oIE.Navigate "file://G:\CIHStaffNews.htm" oIE.Visible = True set oIE = nothing else end if WScript.Quit
Thanks again for your help on this
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Application Block in asp.net using vb.net
- Next Thread: Unzip zipped xml file
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse employees excel exists fade filter forms function html images input listview map mobile module msaccess mysql net number objects open page pan panel pdf picturebox picturebox2 port position print printing printpreview read regex reuse right-to-left save search serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms winsock wpf wrapingcode xml year






