Run a program located on the local machine on a remote machine
Top  Previous  Next


It is not possible to run a program directly from a share like this

DOSR %servername%,15,\\machine\share\myfile.exe

It is also not possible to run a program from a mapped share like this -

DOSR %servername%,15,z:\myfile.exe

Explanation

·The "DOSR" command runs under the local system account. This means that -  
·access permissions = "remote local system", not "domain administrator" - thus direct share access fails.  
·mapped drives is not the same as the ones you see when you log on to the remote machine - thus mapped share access fails.  

There are two ways around this problem

Solution 1: map a temporary network drive for the system account with the "net use" command (use an account with little or no other privileges than the actual access to the share)

DOSR %servername%,15, net use z: \\machine\share password /user:domain\user
DOSR %servername%,15,z:\myfile.exe
DOSR %servername%,15,net use z: /delete


Solution 2: use the DOS command to copy the file through the default hidden administrative share

DOS copy c:\myfile.exe %servername%\c$ 
DOSR %servername%,5,c:\myfile.exe
DOS del %servername%\c$\myfile.exe


Which method is best?

Probably solution 2 -

·No extra accounts are required.  
·No mapped drives are required - you don't have to worry about the possibility of undeleted mapped drives on remote systems.  
·It is faster since account validation and drive mapping takes longer time than a simple copy command.