views:

139

answers:

3

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?

A: 

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

ghostdog74
thanks for your response..The excel has to be opened in that PC to perform other operations.Is there any other exe like psexec to run Excel GUI?
bala
A: 

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"

bala
+1  A: 
  • 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
bala