• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 966
  • Last Modified:

Running a BAT file on remote workstations.

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
SpencerKarnovski
Asked:
SpencerKarnovski
  • 2
1 Solution
 
oBdACommented:
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
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Or run it on all the machines using PSEXEC.
0
 
SpencerKarnovskiAuthor Commented:
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
 
SpencerKarnovskiAuthor Commented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now