Link to home
Start Free TrialLog in
Avatar of gstanl
gstanl

asked on

Run Windows DOS command with PERL

Windows 2008 server.  At Winodws Command Prompt.  
I would like to run a PERL script to set user login times.

This is the windows command:  net user UserName /times:M-Su,06:00-22:00

I don't know how to tell perl to run it as a DOS command.

At present I'm only trying to send a single command as shown.
After I can do that then I will figure out how to run a list through the command.

The goal is to run a perl  script on several servers and update multiple user accounts with out spending a huge amount of time doing so.

thanks -- stan
Avatar of IT_Crowd
IT_Crowd
Flag of Heard Island and McDonald Islands image

Could you have Perl execute a batch file? Inside the batch file, you could have "net user UserName /times:M-Su,06:00-22:00"
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use the Perl "system" function to access the OS:

See: http://www.perlhowto.com/executing_external_commands
Avatar of gstanl
gstanl

ASKER

Excellent, wilcoxon. <br />This is what I was hoping to get and the error output  info is a plus.<br /><br />Yes, I could run a bat file.  But, I wanted to know how to send the DOS command in PERL and the selected solution does that for me.<br /><br />Thanks for the suggestions folks.