bala
bala

Reputation: 2251

Remote execution process in batch mode

The following script is invoking the excel batch file in the remote machine. The batch file will open the excel workbook.

D:>psexec.exe \Host_name D:\Excel.bat

For the above case excel is opened in the background (process) but the workbook is not opened

Is there any way to open the excel book in the remote machine?

Upvotes: 1

Views: 1678

Answers (3)

bala
bala

Reputation: 2251

  • Schedule task has been created in remote PC to invoke the desired batch file
  • Batch file has been created to run the scheduled task (schtasks /run /tn taskname)
  • Run the batch file using psexec.exe \host_name

Upvotes: 2

bala
bala

Reputation: 2251

http://motevich.blogspot.com/2007/11/execute-program-on-remote-computer.html

strComputer = "." strCommand = "notepad.exe"

Const INTERVAL = "n" Const MINUTES = 1

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob") Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now())) errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID)

If errReturn = 0 Then Wscript.Echo "notepad.exe was started with a process ID: " & intJobID Else Wscript.Echo "notepad.exe could not be started due to error: " & errReturn End If

String strComputer = "." means "local computer", On remote computer strComputer = "servername"

Upvotes: 0

ghostdog74
ghostdog74

Reputation: 342373

Running a GUI (excel) remotely to your machine is not that easy. The easier way, is to code vbscript in your Excel.bat to "open" the excel file programmatically and display the cell values to you on the command line. Of course, charts and such would not be available to you then. The other way, get the excel file to your local machine and open it locally

Upvotes: 0

Related Questions