Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running jobs on different server

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have a .bat files that consists of two .wsf file as beloow

REM
REM Create and manipulate .csv file
wscript "Job1.wsf"
REM
REM Load file created from above into Oracle DB
wscript "Job2.wsf"

Job1 manipulates (Excel vlookup) a csv file that is FTP'd on our application server, it then creates a file that we need to load into our DB
Job1 needs to run on our application server where Excel is installed and Job2 needs to run on our web server where our load utility is installed.

How do I go about running one job on one server and anothter job on another server? Any help will be greatly appreciated.

 
Would something like this work for you?

Code:
RemoteExecute "Server1","\\server\share\object1.wsf" 
RemoteExecute "Server2","\\server\share\object2.wsf"

'--Example--
RemoteExecute ".","C:\Program Files\Internet Explorer\iexplore.exe"
RemoteExecute ".","C:\Program Files\adobe\Reader 8.0\Reader\AcroRd32.exe"
'--End Example

Sub  RemoteExecute (objComputer, objFileName)

	Set objWMIService = GetObject("winmgmts:\\" & objComputer & "\root\cimv2")  
	Set objStartup = objWMIService.Get("Win32_ProcessStartup")  
	Set objConfig = objStartup.SpawnInstance_  
		objConfig.ShowWindow = 5
	Set objProcess = GetObject("winmgmts:\\" & objComputer & "\root\cimv2:Win32_Process")  
	errReturn = objProcess.Create(objFileName , null, objConfig, intProcessID)
		
End Sub

I hope this helps.
 
Thanks Dtodd83 for the reply.
Can you tell me how to implement this?

I revised your sample code as belowand save it as a .vbs (and .cmd)file but did not seem to work.

RemoteExecute "Server1","\\Server2\share\Job1.wsf"
RemoteExecute "Server2","\\Server2\share\Job2.wsf"

Sub RemoteExecute (objComputer, objFileName)

Set objWMIService = GetObject("winmgmts:\\" & objComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = 5
Set objProcess = GetObject("winmgmts:\\" & objComputer & "\root\cimv2:Win32_Process")
errReturn = objProcess.Create(objFileName , null, objConfig, intProcessID)

End Sub





 
The sample I gave you is a .vbs. Are you getting any error messages when you run this as a vbs?

I should have asked before, but do you have admin permissions on the two boxes?
 
How frequently do you run these tasks? I would suggest creating a schedule and having it call your wsf files. Spawning remote processes that execute applications or scripts located on shares does not alway work very well. Try copying the corresponding wsf file to one of your servers and then specify that location if you use the code provided by dtodd83.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks for the replies.

It just did not do anything. Currently, both jobs just write to a logfile in a Server2 directory.
I have permission on both boxes

We run these jobs every month, and Job2 is dependent on Job1.
It will be a complete overhaulof Job1 AND job2 for me to schedule one on Server1 and schedule Job2 to run on Server2 with a 1-hr delay.

I was hoping to schedule them in batch so that job2 will execute immediately after Job1 completes.

I put some wscript.echo in both Job1 and Job2 and it did not seem to execute at all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top