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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute File on Server

Status
Not open for further replies.

LuckyDuck528

Programmer
Dec 21, 2004
65
US
Please advise if this is the wrong place to post my question...

I have a file called WebPub.vbs sitting on a Win2003 Server that I would like to be able to execute on the server from my desktop using WinXP Pro. So far, the only part I have had any success with is mapping and disconnecting the drive. I can't seem to figure out the proper way to write the middle section (seen in red) to actually access the drive I mapped, change dir, and then run the file. Is this even possible?

I came across another post similar to this question in which the solution got as far as looking into using "net use". So, I looked into it, and have not had any further success.

Thank you in advanced for your time and help!

Here is my current code:


Code:
Option Explicit

Dim arrServers, inta, objFile, objFolder
Dim objFSO, objWS, strRunMe1, objNet, strRunMe

arrServers = Array ("JHWSDV13")
'***********************************************************
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWS = WScript.CreateObject("WScript.Shell")
Set objNet = CreateObject("WScript.Network")
'***********************************************************
For inta = LBound(arrServers) To UBound(arrServers)
objNet.MapNetworkDrive "H:", "\\" & arrServers(inta) & "\C$"
[COLOR=red]
objWS.Run "cmd net use /c H: \\JHWSDV13\C$\sysapps\batch\WebPub.vbs"
[/color]
objNet.RemoveNetworkDrive "H:"
Next
 
To run locally (on your desktop) the script located on the server:
objWS.Run "H:\sysapps\batch\WebPub.vbs", , True


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you!

Here is what I have now though....

I am getting an error message that says: "The system cannont find the file specified...'H:\sysapps\batch\WebPub.vbs'. I did double check and the file is present on the server. Would I for some reason need to maybe specify the C$ share or give it the server name???

Thanks!

Code:
For inta = LBound(arrServers) To UBound(arrServers)

   objNet.MapNetworkDrive "H:", "\\" & arrServers(inta) & "\C$"

   objWS.Run "H:\sysapps\batch\WebPub.vbs JHWSDV13", , True

   objNet.RemoveNetworkDrive "H:", true, true

Next
 
Have you tried simply this ?
objWS.Run "\\JHWSDV13\C$\sysapps\batch\WebPub.vbs JHWSDV13", , True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, that is what I originally tried and I get the Path Not Found Message
 
there should defo be no need to map a drive

the followign works a treat for me

WshShell.Run "\\serverA\audit$\change.vbs", 1, True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top