Solved

need a net use batch file

Posted on 2014-03-19
9
135 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
 

Author Comment

by:beavis6937
ID: 39941172
that does not work it goes into a loop.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now