Remotely execute an exe file from network shared drive? - windows

So I manage an office with about 150 computers.
I need to run a exe file on each of these machines.
I have placed my file to run on the network sharing drive but to run the file I will have to individually go to each computer and execute it.
I was wondering if it is possible to remotely execute the exe file on all machines in the network, (the machines are named in numbers such as xyzcompany1, xyzcompany2....).
Is it possible?

Have you looked into using PsExec?
https://learn.microsoft.com/en-us/sysinternals/downloads/psexec
My apologies for being vague with the answer the first time.
I would assume since the file is in a network shared folder you would first have to copy the file to the applicable workstation and then execute the program once copied.
To Copy Remote File:
psexec \\workstation123 -s cmd /c copy \\server21\share45\file.exe c:\localpath
Then Run It:
psexec \\workstation123 "c:\localpath\file.exe"

Related

Is their a way to synchronise a directory on a raspberry pi to a laptop using WinSCP

I want to be able to synchronize a directory between my Windows laptop and raspberry pi using WinSCP. By "synchronize" I mean if a file is created in the directory by my raspberry pi, it is automatically placed in predefined directory on my laptop.
I have already set up a WinSCP connection between these two devices.
I was following along using this tutorial https://www.youtube.com/watch?v=ndvEYOQLc4c however I reliazed that this was for an FTP server and I also could not save the .bat file or code file into the appropriate directory as it has it has an administrator lock, so I assume that the method is only for FTB servers.
Edit
I have given myself permissions to save the code files in the appropriate places, however I now receive the error
Host "lynn-vs2.cloudapp.net" does not exist.
Whenever I run the bat file:
winscp.com /script=SyncToLocalScript.txt
pause
Which in turn runs the txt file:
option batch abort
option confirm off
open sftp://sftpuser04:password123!#lynn-vs2.cloudapp.net -hostkey="ssh-ed25519 256 00:69:55:c8:a8:84:01:6d:7c:ff:9f:8c:89:b3:7d:67"
synchronize local C:\Users\****\OneDrive\Desktop\RaspPCAP /home/pi/Desktop/PCapFiles
exit
I am not sure what "lynn-vs2.cloudapp.net" is.

Using wmic to start a process on a remote machine as part of a .bat file

TL;DR - I simply want a way to start a powerpoint presentation on a remote machine via command line / batch file using wmic (not PSEXEC).
A litte info...
I am trying to run a process on a remote machine on our network (POWERPNT.EXE). The purpose of this is that we have a .pptx presentation running on a TV in an entrance and this needs updating with info every day. Traditionally this has been done with VNC and simply editing the file but I want to improve this as the screen is part of a multi monitor set up and this can cause issues eslewhere.
So, my batch file will :
Kill the process on the remote machine running the .pptx
Open the file stored on the remote machine's desktop locally in Powerpoint
After saving the presentation in step 2, run the pptx. slide in auto show mode on the remote machine.
I have 1 and 2 working but am struggling to get the final part to run POWERPNT.EXE on the remote.
Here is my code:
wmic /node:"REMOTE-MACHINE-NAME" process call create "C:\Program Files (x86)\Microsoft Office\root\Office16\POWERPNT.EXE /s \\REMOTE-MACHINE-NAME\SHARED-FOLDER\Presentation.pptx"
I don't want to use PSEXEC as not all operators that need to change this slide will have access to that on their PC's.

Batch file - Remote Copy and Execute issue

I have a batch file that part of it copies a folder and its content to a local directory and then continues through the batch process which then tries to execute the contents of the folder . locally run it works on all wintel os and copies the files from \networkshare\folder*.* to %systemdrive%\temp\ .
I have attempted to use e.g psexec #serverlist.txt -c batfile.bat -s -f -d to copy the file and then execute it remotely how ever the issue is that this will not copy the files when run remotely . I think its a authentication issues after you a have remotely executed the batch file the remote system will not allow me to access/authenticate the networkshare
i have tried xcopy , copy , robocopy .
AFAIK you can only authenticate against the next hop using implicit credentials. Connection attempts from the first hop to a second hop will fail, even if your user has the required permisssions. See e.g. here for an explanation.
Try this:
psexec #serverlist.txt -u %USERDOMAIN%\%USERNAME% -d -c batfile.bat
Use explicit credentials so you're authenticated against the remote host. With that the second hop will be the next hop for your authenticated session. Don't run the script as LOCAL SYSTEM (-s), because that account is restricted to local resources.
I've had this issue in the past. Instead of trying to copy/run the BAT file just run the script things from a UNC path if you are able to. I think the problem lies in the BAT file not actually able to run through PSEXEC and copy like you think. Does it give an exit code?
Here's an example I used a while ago to install Adobe reader. I tried to do it through a batch file but no dice. I could not get it to run within the batch file whether I copied it or not. I can't remember the exact reason, I think it had something with the way a batch file is called in the system and runs in some sort of local context. Don't quote me on that though as I can't remember the exact why.
Here is my code example:
psexec /accepteula \\%computer% -s cmd /c msiexec /i "\\UNC\Software\adobe\Adobe Reader 7.0.9.msi" TRANSFORMS="acrobat7.mst" /qn

How to copy the file from one windows machine to another windows machine in a particular drive using batch script?

In my windows server, am taking SQL DB backup in C drive. I wants to copy this .bak file to some other client windows machine in a particular drive with the current date using batch script. So that i can schedule this batch script using scheduled task. please help me out.
Can anyone, give a script to run this. thanks
Batch files are always tricky to get just right. First I'd open a command line and see if you can copy between two machines using the following syntax:
copy C:\localfile.bak \\remotemachine\c$\Path\remotefile.bak
(where "remotemachine" is the name of the remote machine and "c$" is the drive you wish to copy to). You can then copy this into a batch file and set up a scheduled task.
As for renaming the file to have the current date and time, I suggest you start with this question as it may involve some effort to get it into a format you want.

Problem with relative paths(*.bat + VMWARE + Windows 2003)

This may be a question for ServerFault but I was more interested in understanding the methodology that the OS uses to resolve relative paths. I have two VMware instances of Windows 2003. I am trying to run a batch file that starts running another batch file within its folder path. The script runs fine on one VM but on the other VM it fails to execute with the error:
> The System cannot find the file specified
The script I am trying to run is script.bat:
start /d FOLDERNAME /b /WAIT AnotherScript.bat %~n0%~x0
I have put both my files within the same folder structure under the C:\ drive on both machines. The file AnotherScript.bat resides within FOLDERNAME on both the VMs.
It is not a permissions issue(?) since I show up as an administrator on both VMs.
I was wondering why would I get an unable to resolve relative paths on one machine vs. the ability to resolve it on another machine.
Thanks
First check if the folder in which both are lauching are the same. Try adding ECHO %CD% before calling the 2nd script to check the directory in which it is getting launched.
Also check if the path where the 2nd bat file resides is set in the %PATH% variable in the 1st VM.
Where does command prompt start by default in both VMs?

Resources