Mark Minasi's Tech Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
pdania

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #1 

I'm trying to configure a .bat file that will do 3 things for me:

copy a folder from my PC or source to destination - the destination is on multiple computers at once. thirdly, the copied folder has 2 files, one exe file and the other a vbs file. The exe file when clicked manually, will run the vbs file, but I want to automate this as well, meaning that I want to include in the script a line that runs the exe file after it has been copied to each PC.

for example...

Copy folder to PCA| run exe fileCopy folder to PCB| run exe file

here's my script which I plan to manually run:

@echo onfor /f %%i in (%~d0\VBS1\LONPCs.txt) do start robocopy %~d0\VBS \\%%i\C$\VBS 

The LONPCs.txt file is a list of all the computers that I want to copy the folder to. What I'll like to achieve if possible is to add a line to the above to run one of the files contained within the folder after it has been copied to the destination.

Can someone please help me? Thanks very much Sir!

0
cj_berlin

Avatar / Picture

Senior Member
Registered:
Posts: 243
Reply with quote  #2 
Hi,

yes it's possible, but you'll have to use PSEXEC from Sysinternals to achieve it.

Alternatively, you could rewrite your script in PowerShell and take advantage of its remoting protocols.

__________________
Evgenij Smirnov

My personal blog (German): http://www.it-pro-berlin.de/
My stuff on PSGallery: https://www.powershellgallery.com/profiles/it-pro-berlin.de/
0
pdania

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #3 
Thanks Cj, Do you happen to know how I can incorporate psexec into this script? I'm not very good with scripts, I just need a pointer.

0
jsclmedave

Administrator
Registered:
Posts: 446
Reply with quote  #4 
Quote:
Originally Posted by pdania
Thanks Cj, Do you happen to know how I can incorporate psexec into this script? I'm not very good with scripts, I just need a pointer.



Can you share what the VBS script is doing, that your exe is kicking off, once its copied to the target server?  This may be something a simple PowerShell script can accomplish or even a Group Policy.

__________________
Tim Bolton @jsclmedave
Email: [string](0..20|%{[char][int](32+('527377347976847978324785847679797514357977').substring(($_*2),2))}) -replace ' '  

New to the forum? Please Read this
0
pdania

Still Checking the Forum Out
Registered:
Posts: 6
Reply with quote  #5 
Thanks jsclmedave         

In the folder, there is a runscript.exe which when clicked, runs another script called SophosReInit.vbs, they're both in the same folder. The vbs script is meant to move a host/PC from our old AV Management Server to a new one. The runscript.exe file makes it possible for the users to be able to run the vbs script without admin rights on their PCs.

It's the second part (running the exe) file that is problematic for me to automate. I don't want to go round all the PCs or ask the users to look for a vbs folder on their C drive and double-click the exe file, I would like to automate the entire process. Also for the purpose of learning in case this comes up again somewhere else. [smile]
0
wobble_wobble

Avatar / Picture

Associate Troublemaker Apprentice
Registered:
Posts: 832
Reply with quote  #6 
So you need PSEXEC so you can run the code on the remote machine.

2 options.
Use Robocopy and then psexec
Or use psexec for both actions.
This may help
http://forum.sysinternals.com/copy-and-execute-vbs-via-psexec_topic20066.html

__________________
Have you tried turning it off and walking away? The next person can fix it!

New to the forum? Read this
0
wkasdo

Avatar / Picture

Administrator
Registered:
Posts: 197
Reply with quote  #7 
If these machines are AD joined, a startup script might be easier.
__________________
[MSFT]; Blog: https://blogs.technet.microsoft.com/389thoughts/
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.