-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.

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
abid
  • 25
  • 3

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