Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help writing a little cmd script. 3

Status
Not open for further replies.

SteveAudus

Technical User
Oct 4, 2001
409
GB
Could any of your clever people help me write a little program that would help out myself and my technicians.

We use 2 cmd line codes over and over again, on our NT workstations when we haven't got access to our 2K server,
and I was wondering if it possible to write a script to make their use easier.

I am not a programmer myself, and I really need some help.

The 2 lines are
net user "user name" /domain
to check user details
and
net user "user name" newpassword /domain
to change a user's password.

maybe there is a program out there that does it already.

but just a script that asks for a user name,
then asks if you'd like to change to password,
if yes then you type the password in.
Simple, but I don't know where to start.

Thank you for any help,

Steve Audus
Chaucer School
Sheffield, UK
 
This should be easy... I will come back to you later, or tomorrow after I have looked into running the script through C#. If you get another answer before then, I'll still post back, but you can happily keep the exe program I'll write if it is what you want.
I intend to write a little program that you use the username as an argument. for example:
useradmin -joeb
you would type at the command line.
You will then be asked if you would like to view details, or would like to change password.

Is that the sort of thing you are looking for? (essentially tying the two actions into one script.)

Will
 
Just a quick question... I was trying to use this cmd line tool in order to make sure the program works correctly, but when I use the domain switch with our domain, I don't get information back.
When I just type:
net user "username"
I get all the info about this user...
Plus, when I use the newpassword command, I get that the command completed successfully, but when I logged off and then on again, I used the same password, and nothing happened. So I tried:
net user username newpassword:hufflepuff

I got same message about completing successfully, but when I tried to log back on, I couldn't under my old password, or the one specified above.
This may be because I am using XP. SO would you please post back exactly what you type at the command line using the username dumbo?
example:
net user dumbo /domain circusdomain
net user dumbo newpassword /domain circusdomain

I can then complete this and post it in the forum.

Will
 
Will thanks for all your help on this litle problem.

What I type is as follows

net user "dumbo" /domain

this displays all dumbo's user information,
if I do not use the /domain switch, the cmd
looks at the users on the local system and not on the network.

net user "dumbo" mack468 /domain

this will change his password to mack468, again if I do not use the domain switch it does not find the user.

Thank you again for your help.
Is it possible that in the VB script, that asks for the password it display it as ***** as you type.
That was another problem with using the cmd line,
the password could be seen.

I must try to find time to learn some VB.

Cheers,
Steve
 
Sorry... I have been on a Birthday Holiday for the weekend... only just back at work... I tried to send this project home zipped up, but our email is currently stripping zip files (I forgot!)... so I couldn't work on it on Friday to finish... I'll post back later today...

Will
 
Dear WillShakespeare
Having read your help that you have given , any chance that you could help me out?
I have set up a network in school 100+ machines server 2000 XP clients works ok but printers? I would like a script to run at logon to add printers to the user. You have to add the printers each time on each machine a pain for the Kids.
Some one suggested CON2prt but I don't seem to be able to get this to work any ideas?
The server is called server2k1 the printers are room 22 and room 2a thanks for any help
 
itsfisko

We have the same problem, our users have to pick a printer every time they log on.

The engineer who setup our 2k server gave me this script run in the logon policy for our machines depending on the IT suite in Active Directory, but the problem is we are still on Win Nt 4 workstations, so the script didn't work...it might work for you.

The cmd line script contains one line

rundll32 printui.dll,PrintUIEntry /y /u /in /n\\SERVERNAME\PRINTERNAME

alter it and give it a try.

If it does work please let me know so I can use it when we move to XP clients.

Steve Audus
Chaucer School
Sheffield UK
 
Hi Itsfisko...

I'm afraid I'm not the printer guru of our IT team (Dynamic duo!), but I tried cutting and pasting the above commandline script to my XP command prompt, and it worked perfectly.
What exactly have you done (note emphasis on EXACTLY) to get the error you got?
I ran it both on the workstation and on the W2K server.
I'm thinking you may have a configuration issue (authentication), but you will have to supply more info.
Any scripting I can do only utilizes already installed printers. Even the Add Printers wizard in W2K/XP uses the equivalent of the above command line directive...
Also, have you tried on numerous machines?
Getting a "printui.dll missing" error could be due to the fact that the current logged on user can't access the system folder in which it exists.
Once again, I am not very knowledgeable about printers, so maybe there are some other people out there who can add to this issue, but in the mean time, if you answer my questions above, we may be able to isolate the exact problem...

Will
 
itsfisko (and others)
See my recent post to your original request for help...I explained (better) how to write that little vbs script, using your server and printer shares. As Will states, might be best to try it out with an account that definitely has Admin privileges. But, using it as a login script should work without any problems for any domain user (Admin privileges or not)...

vbs is just a good, relatively simple yet flexible scripting language...especially for login scripts
-Drew
 
Cheers dmanlam thanks for your invaluable help in sorting this problem which I'm sure will help many people.

[medal]
 
Thanks to you all for the help with the last project (printers)
I now have another task ... I have looked at DELPROF to delete the stored folders in DOCUMENTS & SETTINGS but although this works I would like some way of using a script in LOGOFF to remove the last users files to keep the system clean. I have 2 folders in DOC & SETTINGs that contain the desktop I require for all my users one called Pdesktop and one called Sdesktop so I do not want these wiped but I would like everything else (apart from all users /Default users and administrator)wiped on logout any ideas? Thanks once again John [smile] If I only knew today what I will know tomorrow.
 
First to Steve... script is on its way... had a couple of teething problems, but should be done by end of day today in UK time (6pm).

To itsfisko... You could try the following in a batch file for logoff:

move <folder you want to keep> c:\temp
move <folder you want to keep 2> c:\temp

del *.* <from docs & settings>

move c:\temp\<folder you want to keep> c:\<docs & settings>
move c:\temp\<folder you want to keep 2> c:\<docs & settings>

Or something like that. The logic allows you to delete anything that the users may make during their session without you having to know what they have done to delete specifically. (if that makes sense!!) [smile]

Will
 
of course, I just remembered my old DOS days... the command you might need for deleting is probably:

deltree *.* /y

Will

[morning]
 
Why all the scripting? You can just set up a GPO that removes locally cached profiles (in Documents and Settings) at logoff. It doesn't touch the Default User, All Users, or Administrator profiles...just &quot;roaming&quot; user profiles. I'm assuming you want such a feature, because users log in with their own (roaming) profiles?? If so, I'm almost positive this GPO setting doesn't touch local profiles.

Questions:
*Are your Sdesktop/Pdesktop profiles, local profiles?
*Do users access these via a common user (login) account?
*Have you considered setting up a &quot;mandatory&quot; profile (thus preventing users from ever creating their own profile, or modifying the existing ones you've created)?

-Drew
 
Hi the folders in question contain short cuts to applications on the desktop this allows me to have differnt desk tops for differnt areas.All that is left when the user logs off is a folder with their name containing cookies start menu and favorites and it it is this folder i want to get rid of .I have used the delete cached profiles in gpo but it still leaves this folder. If I only knew today what I will know tomorrow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top