1

I am new and seeking help. I manually open a remote desktop to a server and run a batch file I have sitting on that desktop. I want to do this thru VBA. I don't want to see the remote desktop and I would like to know when the batch file is finished running. Here is the code I have found so far. It brings me to the password screen for the remote desktop and I must take it from there manually. What do I need to add to the code to get this done.

TestVar = Shell("C:\windows\system32\mstsc.exe /v:" & "IP Address", 1)

The path for the batch file on the remote is: "C:\users\path\desktop\batch.bat"

Community
  • 1
  • 1
user2358848
  • 31
  • 1
  • 5

1 Answers1

1

If you aren't worried about the logon screen, and want to execute commandfs remotely, you need to take a look at Windows PowerShell

I think this immensely popular StackOverFlow topic could prove useful too (See the answer with 200 upvotes by Jason R. Coombs

Stack Overflow: how to use ssh to run shell script on a remote machine

Community
  • 1
  • 1
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148
  • There is ways to work around it though. Have you seen [this](http://stackoverflow.com/questions/15922300/passing-value-to-excel-inputbox-from-vb-net), and/or [that](http://stackoverflow.com/questions/13147529/vb-net-send-tab-key-to-another-application-window) –  May 08 '13 at 07:00
  • 1
    @mehow yes I have, you will find my comments and upvotes on Sids work – Our Man in Bananas May 08 '13 at 08:32
  • @mehow, I don't have the pswd issue anymore. I can get to the remote desktop. I just need to know how to execute the .bat file that's there. I am working with VBA. Thanks – user2358848 May 08 '13 at 21:03
  • @mehow Thanks. I tried it and it just flashes. Not sure what it is doing. By reading the lne of code, I dont see how it gets me to the remote computer to run the batch file on the remote computer, not the local computer. All the examples I have found seem to run the batch on the local computer. I need remote. – user2358848 May 10 '13 at 13:43
  • it's running it on the calling workstation, you needd to run it as a remote process on the target workstation – Our Man in Bananas May 10 '13 at 14:42
  • @philip, this opens a DOS window, but runs .bat from local machine - strPath = "\\ComputerName\c$\users\Path\Path\file.bat" Shell strPath. This opens the remote desktop, but I need addtl code to run the batch: testvar = Shell("C:\windows\system32\mstsc.exe /v:" & "ComputerName", 1) – user2358848 May 10 '13 at 18:38