-1

I need to create a batch file that will open cmd.exe (as a administrator) with these lines:

cd C:\Program Files\Putty

cd C:\Program Files\Putty>psftp -i XXXXXXXXX.ppk xxxx_test@111.111.111.11 -b C:\UPLOAD\upload.ftp

Can anyone help me?

abelenky
  • 63,815
  • 23
  • 109
  • 159
danny
  • 1
  • 1
    How are you starting this - from an explorer shortcut? There should be a 'run as administator' flag you can check. Or from a command line there's e.g. [this answer](https://stackoverflow.com/q/5944180/243245) – Rup Mar 19 '18 at 13:44
  • Possible duplicate of [How do you run a command as an administrator from the Windows command line?](https://stackoverflow.com/questions/5944180/how-do-you-run-a-command-as-an-administrator-from-the-windows-command-line) – aschipfl Mar 19 '18 at 14:23

1 Answers1

0

DoStuff.bat

@echo off
runas /user:%USERDOMAIN%\%USERNAME% "cmd.exe /K \"cd C:\Program Files\Putty\" & psftp -i XXXXXXXXX.ppk xxxx_test@111.111.111.11 -b C:\UPLOAD\upload.ftp"
  • runas will let you run a command as Administrator (you may need to change the domain/user to match your system, and enter a password).

  • Running cmd.exe /K will run the following commands.

  • The quotes around the commands need to be escaped with \"

I'm having a hard time seeing the difficulty.
Can you explain what you tried, and why it didn't work?

Community
  • 1
  • 1
abelenky
  • 63,815
  • 23
  • 109
  • 159