Solved

need a net use batch file

Posted on 2014-03-19
9
151 Views
Last Modified: 2014-08-06
I like the output net use does when i run it. I need to be able to run it for 500 users and export the output to a text file can anyone help


net user user1
net user user2
net user  user3
net user  user4
net user  user5
net user  user6
net user  user7
0
Comment
Question by:beavis6937
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Schuyler Dorsey
ID: 39940792
To export a single command into a text file, it is rather simple:

net user user1 >> user.txt. Then you can save this with Notepad into a .bat file and double click it to run it.

Are you wanting the bat file to be full of the statements you provided or are you also wanting it to reference a text file for the list of usernames?
0
 

Author Comment

by:beavis6937
ID: 39941106
yes i would like the output of each 7 users in a single txt file.
0
 
LVL 10

Expert Comment

by:Schuyler Dorsey
ID: 39941112
The basic command would be

net user user1 > user.txt
net user user2 >> user.txt

(not the two arrows in the second command. The use of the second arrow tells it to append the results to the end of the text file)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:beavis6937
ID: 39941172
that does not work it goes into a loop.
0
 
LVL 10

Expert Comment

by:Schuyler Dorsey
ID: 39941173
If your batch file is exactly as:

net user user1 > user.txt
net user user2 >> user.txt

There should be absolutely no possibility for it to go into a loop as there is no if/comparison logic..
0
 

Author Comment

by:beavis6937
ID: 39942563
I wanted to be able to have one batch with all the users in it. Then after the batch ran i wanted the output of all users to be in one text file.
0
 

Accepted Solution

by:
beavis6937 earned 0 total points
ID: 39957766
here is a batch but where do i put in my domain.. domain.local?


Wscript.Echo "Retrieving last logon information for " & strUser & "...."

Const ADS_SCOPE_SUBTREE = 2

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://" & strConfigurationNC & "' WHERE
objectClass='nTDSDSA'"
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Set objParent =
GetObject(GetObject(objRecordset.Fields("ADsPath")).Parent)
    strDCName = objParent.dnsHostName


    Set objLastLogon = objUser.Get("lastLogon")

    intLastLogonTime = objLastLogon.HighPart * (2^32) +
objLastLogon.LowPart
    intLastLogonTime = intLastLogonTime / (60 * 10000000)
    intLastLogonTime = intLastLogonTime / 1440

    dtmLastLogon = intLastLogonTime + #1/1/1601#
    dtmLastLogon = DateAdd("n", intTimeZoneBias, dtmLastLogon)
    dtmLastLogon = DateAdd("n", -intDaylightBias, dtmLastLogon)

    If dtmLastLogon > dtmLatestLogon Then
        dtmLatestLogon = dtmLastLogon
    End If
       
    objRecordSet.MoveNext
Loop
0
 
LVL 10

Expert Comment

by:Schuyler Dorsey
ID: 39963877
Ohh this looks like VB or Wscript as oppose to a standard batch file. I assumed since you said batch, it was a bat file.

What exactly are you looking to accomplish? I can look through your script and try to help.
0
 

Author Closing Comment

by:beavis6937
ID: 40243211
this worked out thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question