[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1265
  • Last Modified:

How can I execute remote commands without using psexec?

Hi -
My project requires that I execute remote commands. Does anyone have an example of how I can use Windows Remote Command (rcmd.exe) to do this?  psexec is giving me isssues with NTFS permissions when copying files.  I need this as a backup plan.

Thanks
Rich
0
newtontech4
Asked:
newtontech4
  • 3
  • 2
1 Solution
 
jvuzCommented:
What do you want to do?
0
 
Farhan KaziSystems EngineerCommented:
Greetings Rich,

Why not using WMIC?

WMIC /NODE:"PC1" PROCESS CALL Create Commandline="C:\Hello.cmd"
                         ^--- Remote system name here                           ^----- Executable here.

For more info about WMIC:
WMIC PROCESS CALL /?

For more Info about "Remote Command Service"
http://www.windowsitpro.com/Windows/Articles/ArticleID/40048/pg/2/2.html
http://www.jsifaq.com/SF/Tips/Tip.aspx?id=1951

Hope this helps!
Farhan


0
 
Farhan KaziSystems EngineerCommented:
RCMD consists of client and server components (Rcmd.exe and Rcmdsvc.exe) The client (Rcmd.exe) is a command-line program. The server component (Rcmdsvc.exe) is installed as a service. The RCMD service can be stopped and started locally or remotely.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
newtontech4Author Commented:
hi farhankazi:

Your solution seems perfect - I am almost there.

Question - using your syntax the remote program does not execute.  Is there a need to pass username and password as well?

Thanks
0
 
Farhan KaziSystems EngineerCommented:
If you have domain Administrative rights then there is no need to specify username and password.
Did you check remote machine "Task Manager"? Because WMIC PROCESS is Not Desktop Interactive (means hidden).  So it must be running in the background.

Try following statement and check remote machine's Task Manager.
Click Start -> Run -> Cmd.exe -> OK

WMIC.EXE /NODE:"RemoteMachineName" Process Call Create Calc.exe

If you want to specify username and password then:

WMIC.EXE /NODE:"RemoteMachineName" /User:RemoteMachineName\Administrator /PASSWORD:MyPassword  Process Call Create Calc.exe

Hope this helps!
Farhan
0
 
newtontech4Author Commented:
farhankazi

perfect!  thanks.

/Rich
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now