-3

I want to run a file on remote computer from another computer. I am using this code

set executeAs=%user%
set executeAsPwd=%userPwd%
schtasks /Create /S %machine% /U %user% /P %userPwd% /RU %executeAs% /RP %executeAsPwd% /SC ONCE /TN install /TR %file% /ST 10:11:00
schtasks /Run /S %machine% /U %user% /P %userPwd% /TN install
pause

But it's showing the error access is denied.

abid
  • 25
  • 5
  • Please format this to make the code readable! – Austin T French Jul 17 '16 at 15:35
  • how can i format this code.because it looks ok on my PC – abid Jul 17 '16 at 15:48
  • Have a look at psexec: https://technet.microsoft.com/sysinternals/psexec –  Jul 17 '16 at 15:48
  • please help me according to my code – abid Jul 17 '16 at 15:50
  • hello will any body help me plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz – abid Jul 17 '16 at 15:57
  • You posted your question 27 minutes ago. Stop whining about not getting help yet. This site is not for instant gratification for you. If someone can help you, they will, so be patient and wait. If you're unable to do that, go to rent-a-coder and pay someone there enough money to give you their immediate and undivided attention. – Ken White Jul 17 '16 at 16:01

1 Answers1

0

Your code is obfuscated. We can't check anything about it. This is a more direct way to run programs on remote computers.

To generate a list of computers that are turned on, (in a batch file use %%A rather than %A when typing interactively)

for /f "skip=3 delims=\" %A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %A >> "%userprofile%\desktop\computername.txt"

To run a program use (NB: remote programs are invisible on the remote computer because you can't interfere with a user). Note the use of double backslashes for the command line.

wmic /node:@"%userprofile%\desktop\computername.txt" /failfast:on process call create "c:\\windows\\notepad.exe"

See wmic /?, wmic process /?, wmic process get /?, wmic process set /?, wmic process call /?, wmic /format /?, wmic /node /?, and wmic /failfast /?. Also for /?, net help view (net view /? is short help) and findstr /?.

To see what punctuation means see Trouble with renaming folders and sub folders using Batch

Community
  • 1
  • 1