Solved

Running a BAT file on remote workstations.

Posted on 2013-06-12
4
647 Views
Last Modified: 2013-06-14
Hello, I have to run the following BAT file on all the workstations in our network, thats  400+ workstations.

BAT code.
netsh firewall set service type = FILEANDPRINT mode = ENABLE

netsh firewall set portopening protocol = TCP port = 52965 name = APP-3-DS scope = CUSTOM addresses = 10.##.##.##

netsh firewall set portopening protocol = TCP port = 52966 name = APP-3-AGENT scope = CUSTOM addresses = 10.##.##.##

netsh firewall set portopening protocol = TCP port = 8739 name = APP-3--AGENT-UI scope = CUSTOM addresses = 10.##.##.##

netsh firewall set service type = REMOTEADMIN mode = ENABLE scope = CUSTOM addresses = 10.##.##.##
pause

Open in new window


What options are there for running this on each workstation?   To install this bat you do have to "Press a key to continue".   Is there a bit of code My network manager wants me to run round each pc, login to a profile (he has put the BAT file in the startup folder) and activate it after the profile has loaded.

Surely there has got to be a better way?  
Thanks
0
Comment
Question by:SpencerKarnovski
  • 2
4 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 39241742
Remove the last line that says "pause" to remove the need for a key press.
Then use a computer startup script (not a user logon script) in a GPO applied to the  workstations in question.
Assign computer startup scripts
http://technet.microsoft.com/en-us/library/cc779329(v=ws.10).aspx
0
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 39242957
Or run it on all the machines using PSEXEC.
0
 

Author Comment

by:SpencerKarnovski
ID: 39243813
Hello Lee,

I was going to suggest using PsEXEC.  Could you help me with the syntax (even if we do use GP as suggested, this would still be extremely beneficial to me to be able to run an application on a workstation.

So, for example.  

We have a BAT file stored on Z:\SCRIPTS\BAT.BAT

We want to run that BAT file, using PsEXEC, on the workstation:

\\ICT101

Here is the usage syntax for PsEXEC.

http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx

Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,... ] cmd [arguments]

Open in new window


Something like.

C:\psexec \\computer \filelocation \file \user \password

Then I could create one BAT file, add all the computers in our network and run that just once.  I know I could do it with GPs, as someone suggested, but  I would certainly like to know how to do it from command line.  There are many times I need to run scripts on workstations that have users logged in.

Thanks.
0
 

Author Comment

by:SpencerKarnovski
ID: 39244576
Ok, figured it out.

How can I run multiple commands (one for each workstation) from this single batch file.

C:\>C:\PSTools\PsExec \\SMR05 -s -c C:\FW.bat

That commands runs the BAT file on SMR05, but say I wanted to run on all the computers in SMR, so something like;

C:\PSTools\PsExec \\SMR05 -s -c C:\FW.bat
&
C:\PSTools\PsExec \\SMR06 -s -c C:\FW.bat

And so on.  Also, I'm having to drag the PsExec into a CMD,then type the rest of the command.   When I try to create a BAT file, to do it automatically, the CMD window opens for a second, then closes without executing the command.

So, say I create the following

C:\PSTools\PsExec \\SMR05 -s -c C:\FW.bat in notepad, and save that as RUN.bat, then click RUN.bat that nothing happens.

I could go research this, but I pay for this, so someone else can show me instead !

Thanks.

OK, this seems to work.

start c:\PsExec.exe \\ICT211 -s -c c:\FW.bat
start c:\PsExec.exe \\ICT212 -s -c c:\FW.bat
start c:\PsExec.exe \\ICT213 -s -c c:\FW.bat
start c:\PsExec.exe \\ICT214 -s -c c:\FW.bat

This executes each command in a separate CMD - can you see any issues with this?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
LINUX ZIP - UNCOMPRESS WINDOWS PATH 3 58
regex to extract ip:john 17 57
unix example issues 18 47
Recursive folder search vbscript 7 29
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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