NET USER 
Author Message
 NET USER

Dennis,

I am so sorry.  The command line for net user is NET USER username password.
I need to run the net user command alone as follows to get a list of current
user names, so I can query and change passwords for all user names that
start with a T.

 C:\>net user

User accounts for \\computername
_____________________________________________________________
Administrator                Guest                Test1
SSleepy                        GermanGuy        Test2
The command completed successfully

Then I would run the command NET USER test2 password.  This is its output.

C:\>net user test1 password
The command completed successfully.

Again, I really apologize.  I do need this as soon as possible and really
appreciate your help.  I was up late as well, but generating reports through
Access.  I wish I had your skills as a programmer.



Mon, 23 Dec 2002 03:00:00 GMT  
 NET USER

Hi Lisa!

This _should_ run, but don't blame me if it doesn't ;)
As said, I don't have NT at home to test it. It's a quick hack with little
errorcheck. Hope it works.

(...)

Quote:
>  I wish I had your skills as a programmer.

(...)

Oh... thanks for the compliment, but I'm only a network admin who tries to
keep his work as easy as possible.
I'm the laziest person I know ;)

Cheers

Dennis

---< snip >---
<?xml version="1.0" encoding="ISO-8859-1"?>
<job id="NetUser">

<script language="VBScript">
<![CDATA[
Function VBInputBox(strLabel)
 VBInputBox = InputBox(strLabel, "Input required")
End Function
]]>
</script>

<script language="JScript">
<![CDATA[
var objShell = WScript.CreateObject("WScript.Shell");

/* Don't know if the next line works;
   if not, give the full path and maybe a leading "%comspec% /c" */
objShell.Run("net user > c:\\netuser.txt", 0);

var strUser = VBInputBox("Change password for all users\nbeginning
with...");
var strPassword = VBInputBox("Change password for all users\nbeginning with
" + strUser + " to...");

var objFSO = WScript.CreateObject("Scripting.FileSystemObject");
var netuser = objFSO.OpenTextFile("c:\\netuser.txt");

while(!netuser.AtEndOfStream){
 var strReadLine = netuser.ReadLine();

 var RegEx = new RegExp("(" + strUser + "\\w*)\\s+(" + strUser +
"\\w*)\\s+(" + strUser + "\\w*)","i");
 RegEx.exec(strReadLine);

 /* A problem here. I don't know how to reset RegExp.$1.
    The script should run anyway, but some users will have
    their password changed more than once (time consuming) */
 if(RegExp.$1 != ""){
  /* Don't know if the next line works;
     if not, give the full path to net.exe
     and maybe a leading "%comspec% /c".
     And you will have to change the syntax since I don't know it ;) */
  objShell.Run("net user " + RegExp.$1 + " " + strPassword, 0)
 }

 if(RegExp.$2 !=

  // see above comment
  objShell.Run("net user " + RegExp.$2 + " " + strPassword, 0)
 }

 if(RegExp.$3 !=
{
  // see above comment
  objShell.Run("net user " + RegExp.$3 + " " + strPassword, 0)
 }

Quote:
}

]]>
</script>
</job>
---< snip >---


Tue, 24 Dec 2002 03:00:00 GMT  
 NET USER
Thank you so much.  Yes, it does work with one minor glitche.  Well,
2....1 - it does not create the file for me and 2 it only changes the first
username it finds that starts with a t only after I create the file
manually.  Any thoughts?

You don't realize how e{*filter*}d I am with your script changing one
successfully.  What is this written in?  A combination of XML, VBscript and
Jscript?  How did you learn?  I am reading books and cutting bits and pieces
of what I need, but I am not getting results fast enough.  Believe me, I too
am one of the laziest people as well, I find that fastest way from point A
to B and that is why I am trying to do scritping now.

Hope your day is full of sunshine :-)

Best Regards,
-Lisa


Quote:
> Whoops... something got lost while tranferring my message to the server...
I
> don't know how, but I've attached the correct version to this posting.

> Sorry,

> Dennis



Tue, 24 Dec 2002 03:00:00 GMT  
 NET USER
If everything fails, go get Perl from http://www.activestate.com or mail me
to send you a precompiled version and try this:

---< snip >---
#!/usr/bin/perl -w

system("net user > C:\\netuser.txt");

print("Change password for all users beginning with: ");
chomp($strUser = <STDIN>);
print("Change password for all user beginning with \"$strUser\" to: ");
chomp($strPassword = <STDIN>);

open(NETUSER, "C:\\netuser.txt");

while(<NETUSER>){
 /($strUser\w*)/i;
 system("net user $1 $strPassword");
 /\w+\s+($strUser\w*)/i;
 system("net user $1 $strPassword");
 /\w+\s+\w+\s+($strUser\w*)/i;
 system("net user $1 $strPassword")

Quote:
}

close(NETUSER);
system("del C:\\netuser.txt")

# EOF
---< snip >---



Tue, 24 Dec 2002 03:00:00 GMT  
 NET USER
Dennis,

I downloaded Pearl 6.15 and it still doesn't work for me.  Can you complie
and send back to me?  We are so close and I am starting to really sweat it
here.  This is due Monday and I have to get it completely functioning this
weekend.  I have all trust in your capabilities since all of your previous
releases to me have worked.  I was wondering if the netuser2.wsf was setup
to change multiple users or not.  It doesn't seem to do that function
either.

Please do not give up on me.

Thank you,
Lisa Parks


Quote:
> If everything fails, go get Perl from http://www.activestate.com or mail
me
> to send you a precompiled version and try this:

> ---< snip >---
> #!/usr/bin/perl -w

> system("net user > C:\\netuser.txt");

> print("Change password for all users beginning with: ");
> chomp($strUser = <STDIN>);
> print("Change password for all user beginning with \"$strUser\" to: ");
> chomp($strPassword = <STDIN>);

> open(NETUSER, "C:\\netuser.txt");

> while(<NETUSER>){
>  /($strUser\w*)/i;
>  system("net user $1 $strPassword");
>  /\w+\s+($strUser\w*)/i;
>  system("net user $1 $strPassword");
>  /\w+\s+\w+\s+($strUser\w*)/i;
>  system("net user $1 $strPassword")
> }

> close(NETUSER);
> system("del C:\\netuser.txt")

> # EOF
> ---< snip >---



Tue, 24 Dec 2002 03:00:00 GMT  
 NET USER

It runs without any error, but doesn't change anything for me.  As you can
tell, I am new scripting in WSH, let alone VBscript or Jscript.  I do not
know if it is running net user, but when I login again, the pasword has not
been changed.  I have now been given repreive to this being due today.  I
still need to have this working and hope you and Dennis choose to continue
to assist.

I can walk through the code and understand what it is doing, but do not know
why it is not changing anything for me.  I will continue to work on it.
Thank you for all of your help.  Let me know if I can give you more
information to figure out why this is not working.

Thank you,
Lisa Parks


Quote:
> Have a look at the attached. It runs the net user command, captures output
> and can examine each individual user. If they match up to your
specification
> you can either rename them with an inputbox or give them a generic
password.

> If it doesnt work or you need some more advice please post again. Some of
> the stuff in the code needs changing to your requirements but it shouldnt
be
> too hard.

> --
> Dominic



Fri, 27 Dec 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Win2K/Net user group enumeration with LDAP?

2. Net User

3. net user?

4. NET USER with Shell.Run?

5. IE setting for all net users

6. Net User Command

7. Mapping Net Drives with User Permission

8. net loss, net gain

9. Please HELP (Net Stop / Net Start Spooler)

10. run net.exe (net send) with external commands

11. Run .NET script code and handle .NET events from inside IE with VsaControl

12. adding user account to "Users" container

 

 
Powered by phpBB® Forum Software