Psexec – Start Một Process Từ Xa Bằng Psexec - WIKI PAGE

Làm thế nào để start một ứng dụng trên một PC khác? Thông thường để có thể start một process trên một máy tính khác chúng ta phải remote desktop vào máy tính đó và start chúng bằng nhiều cách. Vậy làm thế nào chúng ta start một process chúng ta muốn chỉ thông qua cmd của máy tính hiện tại.

psexe-tuanpham-dragonbot-it-phamtuan

Để giải quyết được vấn đề trên chúng ta có thể sử dụng công cụ Psexec, tải về tại đây.

PsExec là một command-line tool, nó cho phép bạn start một process trên một máy tính từ xa và hiển thị console output trên giao diện console tại máy local. PsExec là một trong 11 tools của Sysinternals gọi là PsTools.  PsTools không cần cài đặt. Cú pháp của Psexec như dưới đây, các bạn có thể xem thêm tại ss64

psexec \\computer[,computer[,..] [options] command [arguments] // Hoặc psexec @run_file [options] command [arguments]

Ví dụ dưới đây giúp tôi start process tên là MyExecute.exe trên máy tính với IpAddress là 172.16.25.6

psexec -accepteula \\172.16.25.6 "D:\Softs\MyExecute.exe"

Với lần sử dụng đầu tiên, Psexec sẽ hiện hộp thoại thông báo và yêu cầu bạn chấp nhận điều khoản cho việc sử dụng ứng dụng này. Nếu bạn muốn chặn hộp thoại này, hãy thêm đối số này [-accepteula] vào trước các command khác.

psexe-tuanpham-phamtuan

Ví dụ dưới đây cho tôi biết thông tin IpAddress của máy 172.14.36.3

psexec -accepteula \\172.14.36.3 ipconfig

Lưu ý rằng để có thể chạy được những lệnh trên chúng ta phải:

  • Enable $Admin Shares: xem hướng dẫn tại đây
  • Máy local phải có credential hợp lệ để remote vào máy remote: xem thêm tại đây hoặc đây
  • Nếu các máy chung Domain thì bạn chỉ cần add user domain của máy local vào máy remote mà không cần tạo credential.

Psexec cũng có thể cho phép bạn start process dưới quyền một account khác:

psexec \\172.14.36.3 -u YourUserName -p YourPassWork ipconfig

Psexec cho phép bạn start process dưới quyền một account khác nhưng bản thân nó phải được start dưới account có quyền access vào máy remote.

Inside PsExec

PsExec starts an executable on a remote system and controls the input and output streams of the executable’s process so that you can interact with the executable from the local system. PsExec does so by extracting from its executable image an embedded Windows service named Psexesvc and copying it to the Admin$ share of the remote system. PsExec then uses the Windows Service Control Manager API, which has a remote interface, to start the Psexesvc service on the remote system.

The Psexesvc service creates a named pipe, psexecsvc, to which PsExec connects and sends commands that tell the service on the remote system which executable to launch and which options you’ve specified. If you specify the -d (don’t wait) switch, the service exits after starting the executable; otherwise, the service waits for the executable to terminate, then sends the exit code back to PsExec for it to print on the local console.

Psexec luôn có những hạn chế về security nên cân nhắc khi dùng.

Phạm Tuân

Hãy chia sẽ nếu thấy hay

  • Facebook
  • In
  • Thêm
  • X
  • Tumblr
  • Pinterest
  • Túi
  • LinkedIn
Thích Đang tải...

Có liên quan

Từ khóa » Cài đặt Pstools