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
Solved

need a net use batch file

Posted on 2014-03-19
9
146 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.

838 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