Solved

need a net use batch file

Posted on 2014-03-19
9
148 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
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.…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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