[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

need a net use batch file

Posted on 2014-03-19
9
Medium Priority
?
158 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

834 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