# How to copy & run batch file remotely



## yogeshsam (Sep 21, 2009)

Hello,
I have created batch file on my server m/c, The operation of my batch file is as follows,

1. I have log file in my server which records client login logout time,
2. For particular user if the logout log is not exist(means application is still on & it is consuming license from my license server) then i am reading the clients last login time & date,
3. Checking the date & time difference with current date & time
4. If the time difference is greater than 8 hrs & date difference is greater than 1 day
5. Then, copy the killprocess.bat file from server to client machine & execute that batch file on client machine remotely to kill that particular process. 
-----
killprocess.bat file has one liner code,
cd\
taskkill /F /IM techservice.exe
------
Issues/ Problem i am facing are,
1) for copying killprocess.bat from server to client machine requires shared folder on client pc. But my domain restrictions doesn't allow me to share folders in client pc.
2) even if i manage to copy the killprocess.bat file somehow, for executing that batch file remotely using PSEXEC command also requires shared path where the killprocess.bat is kept - How can i execute process remotely without having shared folder in client pc?
or Is there any alternate to execute batch file remotely?

Thanks in advance.


----------



## Squashman (Apr 14, 2005)

I don't recall psexc ever needing a shared folder to execute it. It temporarily copies the file you want to execute over to the remote computer, executes it and then exits. Psexec is the perfect solution for this.


----------

