|
Hi,
How to map drive by checking domain name when user log on,such as when user log on domain 1 map network drive = X
and if user log on domain 2 map netwrork drive =Y
I have write a script it as below details,tt seemed didn't work.Plese help. Thanks in advance
Option Explicit
Dim objSystemInfo
Dim objWSHShell
Dim strLogonServer
Dim objNetwork
Dim strDriveLetter, strRemotePath
Set objWSHShell = Wscript.CreateObject("Wscript.Shell")
strLogonServer = objWSHShell.ExpandEnvironmentStrings("%LOGONSERVER%")
WScript.Echo "Server Name is :" & strLogonServer
Set objSystemInfo = CreateObject("ADSystemInfo")
WScript.Echo "Site Namen is: " & objSystemInfo.SiteName
strDriveLetter = "X:"
strRemotePath = "\\domainname\home\"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
WScript.Quit
|
|
|
|
|
I don't exactly what you're looking for because your code doesn't check which domain the user logged into. But, here's an example of where the det the domain name:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
|
|
|
|
|
Thank Dave
How to check domain if i have multiple domain and map network drive. Thanks in advance.
|
|
|
|
|
Why don't you use a script in the 'NETLOGON' share of one of the DC's of the domain you're connecting to ?
|
|
|
|
|
Hi,
Because of user working on multiple domain. I can't specific drive for them. I think it should be check domain before map network drive. Plese suggest me. Thank you
|
|
|
|
|
|
What did I tell you about posting this crap?
|
|
|
|
|
The NETLOGON share exists on any domain controller of any Active Directory domain.
There you can put some scripts that will be executed for users, if activated in their account management window.
Thus, the only things you have to do are :
- create a script (.bat or .cmd) in the netlogon share of one of the domain controllers that will connect a given drive letter to a given share on a particular server
For example :
net use H: \\myserver\users$\%username%
net use I: \\mysecondserver\common
- in the user's account management window, just give the filename of your script in the 'Connection script' field
The script will be executed when the user opens his session.
If you do that on both domains, no need to check for which domain is involved : the entire login process will take care of that for you.
|
|
|
|
|
Considering I already showed you how to get the domain the user is in, writing the IF statement to see if it matches whatever your requirements are for a particular drive mapping is on you.
|
|
|
|
|
Hi
I have write it as below details;
Set WshNetwork = WScript.CreateObject("WScript.Network") WScript.Echo "Domain = " & WshNetwork.UserDomain
strDriveLetter = "J:"
strRemotePath = "\\Domain\home\"
It didn't map network drive. Plese suggest me. Thank you
|
|
|
|
|
I can't tell you the exact code to use.
I have no idea what you're checking for (not that your code does ANY checking of anything what-so-ever!) and no idea what your server name and share names are. If this code is EXACTLY what you are running (no substituting "Domain" for anything,) you also do not know enough about Windows networking to take an intelligent guess at what you're supposed to be doing.
You cannot map a drive to a Domain. You map a drive to a \\<ServerName>\<ShareName>.
|
|
|
|
|
Thank you Dave. I will learn more.Sorry for make you confusing.
|
|
|
|
|
Hello, i have a problem, in my application i have a datagridview with rows, i can insert rows without any problem, i have a condition when its true i will remove this row, to know wich index has the row i have made a function, and i call it and the return value is correct but the next code line doesnt execute, can anybody help me??
Thanks and sorry for my english.
Dim row_to_delete as intenger
...
for i....
if .... then..
row_to_delete=find(i)
datagridview.rows.removeat(row_to_delete)' this line seems to doesnt execute
...
----------------------------------
public function find(byval code as integer) as integer
dim index_row as integer
for x =0...
if code =datagridview.item(0,x).value then
index_row=x
return index_row
end function
|
|
|
|
|
Put your code snippets within <pre> tags to post it in the forum, and try to put the relevant code just as you have it in your application. RemoveAt method in DataGridViewRowCollection might fail in many cases. Have a look at this[^] to see when it can fail.
|
|
|
|
|
If you delete a row, it screws up the enumerator because all the rows index positions change.
The easiest way to delete a bunch of rows in one operation, is to reverse the collection of row indexes and delete them from highest number to lowest number, the collection doesn't get screwed up that way.
If you don't yet know what rows you want to delete and are processing them based on some value within the table, them do exactly the same thing, start the search at the end of the collection and work backwards.
For X as integer = ( datatable.rows.count -1 ) to 0 step -1
If datatable.rows(X).columns(y) = "value" then datable.rows.removeAt(X)
next
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
It works! thank you very much for the reply
|
|
|
|
|
Hi,everyone!I have a XML, its structure was like below:
<Height>
<Standard>4721
<PN>1.6
<A DN="250">300</A>
<A DN="350">400</A>
<A DN="450">500</A>
<A DN="550">600</A>
</PN>
<PN>2.5
<A DN="250">300</A>
<A DN="350">400</A>
<A DN="450">500</A>
<A DN="550">600</A>
</PN>
</Standard>
</Height>
I want to get the selected node's text,for example,when PN = 1.6,DN = 250,the selected node's text was 300;PN=2.5,DN=350,the text should be 400.I tried use "for each node in childnodes",but it returned "1.6 300400500600".How could get the node I wanted?
I think that should be first selected "PN",and then get each childnode in <pn>. But I don't know how to do this
PLZ give me some help,thx!
|
|
|
|
|
System.Xml has a method SelectSingleNode, which requires an xPath expression in order to work. Your method should look somewhat like the following:
Sub GetSelected(string _PN, string_ DN)
' Put some code here to read your XML document into a XMLDocument variable,
' called XDoc for instance.
XmlNode _XN = XDoc.SelectSingleNode("/Height/Standard/" + _PN + "/A")
End Sub
(yes, I'm not a hero in vb, 5 pts if you guess my 'dialect').
Hope this steers you in the right direction!
"My personality is not represented by my hometown."
|
|
|
|
|
Hello,Eaverae! Your suggestion is helpful for me to get more details about the method "SelectedSingleNode".Thank you! I have got my solution like below:
For Each node1 In list1
Dim val As String
val = node1.Attributes("PN").Value
If val = TextBox1.Text Then
Dim list2 As XmlNodeList = node1.SelectNodes("Height")
Dim node2 As XmlNode
For Each node2 In list2
Dim val2 As String
val2 = node2.Attributes("DN").Value
If val2 = TextBox2.Text Then
TextBox3.Text = node2.InnerText
End If
Next
End If
Next
What's more, I have change the XML element
<PN>
to
<PN PN="1.6">
|
|
|
|
|
I am learning to program in VB.NET(2008 Express) and also learning to use version control software (TortiseSVN).
I am creating simple projects with VS while I learn the language(Using the book VB 2008 Step by Step ).
I have not been able to determine if I should put all the files in the project directroy under version control and if not what files and folders to exclude.
I am not sure what the files in the project directory do, any infomation would really be helpful.
eg of contents of project folder.
bin (folder)
My Project (folder)
obj (folder)
*.vb
*.resx
*.vb
*.sln
*.suo
*vbproj
*.vbproj.user
Thanks cages
|
|
|
|
|
There is no need to keep the bin folder and its contents in source control. Same applies to the suo and vbproj.user files.
SUO files contain information about IDE settings for the user while .user contain similar information for the corresponding vbproj.
|
|
|
|
|
I will try working on a simple project not including the:
obj and bin folders
.suo and .vbproj.user files
I can't use VisualSVN as I am working with the Express version of VS. Does any one know what files VisualSVN puts under source control?
Is there a document that explains the project structure for VB.NET?
Thanks,
cages
|
|
|
|
|
I'm not familiar with TortiseSVN; my shop still uses Visual Source Safe (pray for me.)
Our practice is to link the project into version control through VS; in the Solution Explorer, right click on the root object -- either your one project or your solution containing several projects -- and select Add Project to Source Control. It has been a long time since my Visual Studio was configured so I don't remember the process, but that should be easy enough for you to find. I'm pretty sure you can add other versioning databases than just VSS.
With Source Safe, adding a project or solution will add the code files, the folders holding code files, and the solution and project files, but not the bin or object folders. Presumably, this is because those tend to change very frequently during development, and can be reconstructed easily by recompiling the code.
|
|
|
|
|
Gregory.Gadow wrote: I'm pretty sure you can add other versioning databases than just VSS.
If you want subversion integration in Visual Studio, AnkhSVN is one plugin that facilitates this. I personally preferred TortoiseSVN (which is an Explorer shell extension).
|
|
|
|
|
I have found VisualSVN Server (free) and AnkhSVN plugin (free) a good combination.
Free + Free = just how we like it......
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|