1.

Solve : How to copy & run batch file remotely?

Answer»

I have created one batch file on server, such that -
If the client is logged in into server for more than 8 HRS then kill the perticular task of that client remotely.
server = has a log of CLIENTS - i am reading the client login & logout logs from the log file.
Uptill this all ok..
----
problem 1) = But for killing the task i need to run taskkill cmd on client pc,
i have created that file also, but the problem is How do i send that file to the client machine? because i do not have the folder shared in my client pc & sharing permissions are also not there.
problem 2) = and also for executing taskkill batch file remotely - i can use PSexec cmnd. but for sending that cmnd, i have to pass on the client domain credentials(username & password) which i do not have, I have the credentials of administrator account but system doesn't accept those.
eagerly waiting for the answer, thankyou in advance.Are you the IT guy or something? Maybe you're doing something you're not allowed to do in the first place.Why do u think so?
As i said folder sharing is not allowed, it means i'm working in domain & domain is not having sharing rights, so my quastion was without folder sharing - How would i transfer files on remote machine.
& secondly about omiting credentials means i cannot enter all the domain users credentials in a batchfile, so quastion was - Can i make use of administrator password which is comman for all.YES you can. It would need to be a local or service account that every PC has been set up to give admin rights. You could also prompt for the domain/userid and password in the batch and use variables so the password is not HARD coded in the batch. If you do not have admin right then you will not be able to do this. Dear wbrost,
Yes iam having the administrator username & password of those client machines,
and It is ok for me to hardcode the variables (username & password) because all my client machines are having same administrator username & password.(administrator account is also exists).
Note:- all the machines are using domain account
but how would i go forward.you could try the following:

map the network drive to the remote system.
copy down the batch or using echo make on on the client system.
set up a scheduled task using the at command to start the batch at the desired time.
remove the mapped network drive and move on the the next system.

rinse and repeat

or you could ask the domain admin to set up a service account to use fro the PSexec commands.Quote from: wbrost on September 17, 2009, 07:01:34 AM

you could try the following:

map the network drive to the remote system.
copy down the batch or using echo make on on the client system.
set up a scheduled task using the at command to start the batch at the desired time.
remove the mapped network drive and move on the the next system.

rinse and repeat

or you could ask the domain admin to set up a service account to use fro the PSexec commands.

Dear wbrost,
I have created batch file on my server m/c, The operation of my batch file is like this,

1) I have log file in my server which records client login logout time, For particular user if the logout log is not exist(means application is still on & it is consuming license from the license server) then i am reading the clients last login time & date,
2) Checking the date & time difference with current date & time
3) If the time difference is greater than 8 hrs & date difference is greater than 1 day
4) Then, copy the killprocess.bat file from server to client machine & execute that batch file on client machine remotely to kill that perticular process.
-----

killprocess.bat file has one liner code,
cd\
taskkill /F /IM processname.exe
------
Issues/ Problem i am facing are,
1) for copying killprocess.bat from server to client machine requires shared folder on client pc. as said earlier 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 the shared path where the killprocess.bat is located - How can i execute process remotely without having shared folder in client pc? is there any alternate to execute batch file remotely?

I thing now i have explained my problem in more detailed.
Eagarly waiting for the reply, Thanks in advance. 1) if you have access to the system you can map a network drive using the administrative share.
example: \\computername\c$
this will give access to the root of the c drive on the system computername


2) using the at command you can schedule a remote task to execute at a specific time.

The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.

if you still have questions please let me know.Dear wbrost,
You are correct,
but as i said earlier my domain client pc doesn't have share folders, instead the sharing permission is not exist.
and i suppose the mapping drive is possible only if the client machine has the shared folders in it.
pls correct me if i am wrong.there is actually a shared folder by default. This is called an administrative share. The administrative shares can be accessed by putting a dollar sign ($) after the drive letter.

example for the administrative share for the C drive would be: \\computer\C$

to see if the system has the administrative share active do the following:

Right click on my computer
click on manage
expand shared folders
click on shares.Dear Wbrost,
I'm getting following error while accesing those folders,
Error 5: Access Is Denied.

Is there any other alternate to copy file remotely (without sharing)
------
Can i make use of FTP for pushing batch file?
But i suppose FTP doesn't pushes anything, somebody has to push data to him & Pull data from him,
pls correct me if i am wrong.
(If above happens through FTP, i can make use of AT command to schedule that batch script as suggested by you.)How are you thrying to access the computer when you get the error message?

you can test access out side the command line by doing the following:

click on start
click on run
type in \\computername\C$

when prompted enter the following:
user name - computername\accountname
password - password for account


you need to make sure you are connecting as the account on the remote system.

please see the below command switches for reference:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[[emailprotected] domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]



Discussion

No Comment Found