473,732 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run bat file on remote machine

What is the best way to have my windows app run a .bat file on a remote
server? The .bat will need to run as an admin on the remote machine.
Additonally I need for my windows app to wait for the .bat to finish.

Aug 26 '06 #1
7 10152
have a look at the process names pace assuming you have a share or some way
to access the remote machine, this should work.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Ctal" <wi********@yah oo.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
What is the best way to have my windows app run a .bat file on a remote
server? The .bat will need to run as an admin on the remote machine.
Additonally I need for my windows app to wait for the .bat to finish.

Aug 26 '06 #2

"Ctal" <wi********@yah oo.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
| What is the best way to have my windows app run a .bat file on a remote
| server? The .bat will need to run as an admin on the remote machine.
| Additonally I need for my windows app to wait for the .bat to finish.
|

There is nothing in .NET that makes this possible, even WMI is not able to
start a process as a local admnistrator on a remote system.
Take a look at psexec at
h<ttp://www.sysinternal s.com/Utilities/PsExec.html>, this utility can run a
process on a remote system with specified credentials, from your code you
can start psexec using Process.Start.

Willy.
Aug 26 '06 #3

"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uq******** ******@TK2MSFTN GP05.phx.gbl...
| have a look at the process names pace assuming you have a share or some
way
| to access the remote machine, this should work.
|

Alvin, The OP's requirement is to run a batch file remotely, this is not
possible using this namespace. You need a client/server style application
like Sysinternals - www.sysinternals.com psexec.exe to run a process
remotely.
Willy.
Aug 26 '06 #4
I'm not sure what you mean here, the process class can start a local or
remote process. If you mean the bat file, then you are right, it won't start
it but that can be fixed easily by writing a small exe to either call the
bat file or reproduce the bat file functionality in the exe.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uq******** ******@TK2MSFTN GP05.phx.gbl...
| have a look at the process names pace assuming you have a share or some
way
| to access the remote machine, this should work.
|

Alvin, The OP's requirement is to run a batch file remotely, this is not
possible using this namespace. You need a client/server style application
like Sysinternals - www.sysinternals.com psexec.exe to run a process
remotely.
Willy.


Aug 27 '06 #5


"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
| I'm not sure what you mean here, the process class can start a local or
| remote process. If you mean the bat file, then you are right, it won't
start
| it but that can be fixed easily by writing a small exe to either call the
| bat file or reproduce the bat file functionality in the exe.
|
| --
|

While the Process class can be used to 'monitor' processes on remote
machines, it can't start (that is run a process remotely) or stop a process
on a remote machine. The Process class call's CreateProcess or
CreateProcessWi thLogon, and these API's can only create local processes
(Windows has no API to create processes remotely).
If you have to run a process remotely, you have to resort to WMI, or another
C/S (like Psxec.exe) kind of architecture, here the 'client' requests the
'server' to start a process on a remote server (where it gets created as a
local process).
Willy.
Aug 27 '06 #6

Willy Denoyette [MVP] wrote:
"Ctal" <wi********@yah oo.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
| What is the best way to have my windows app run a .bat file on a remote
| server? The .bat will need to run as an admin on the remote machine.
| Additonally I need for my windows app to wait for the .bat to finish.
|

There is nothing in .NET that makes this possible, even WMI is not able to
start a process as a local admnistrator on a remote system.
Take a look at psexec at
h<ttp://www.sysinternal s.com/Utilities/PsExec.html>, this utility can run a
process on a remote system with specified credentials, from your code you
can start psexec using Process.Start.

Willy.
Thanks Willy, that looks promising. The other way I was approaching
this was with ado commands, my remote machine has sql server installed.
I was going to call xp_cmdshell and use that to launch the .bat (or
exe). That works if the SQL service account has the necessary
credentials (in my case it does)

Thanks all for the suggestions.

Aug 29 '06 #7
You are right Willy. I tried unsuccessfully to do this but it would only
fail silently. I swore I did this a couple years ago but when I went back to
check the code, it wasn't a actually a mapped drive, it was
d:\somepath\som efile.

--
_______________ _________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>
"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uq******** ******@TK2MSFTN GP05.phx.gbl...
| have a look at the process names pace assuming you have a share or some
way
| to access the remote machine, this should work.
|

Alvin, The OP's requirement is to run a batch file remotely, this is not
possible using this namespace. You need a client/server style application
like Sysinternals - www.sysinternals.com psexec.exe to run a process
remotely.
Willy.


Aug 30 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3400
by: Rocket Hawk | last post by:
Hello All, I am using windows 2000 server IIS 5.0 i was trying to run bat file from asp page and getting: Access Denied but when i run the bat file from the command prompt on the local server, it's running good the bat file copying files from target computer in the LAN to the local computer, o.k
9
8848
by: Doug at SAU | last post by:
I need to run a batch file on a remote machine from an ASP page. I dummied up a test ASP page as follows: <% Set WshShell = Server.CreateObject("Wscript.Shell") wshshell.run "c:\inetpub\wwwroot\logasp\getdr.bat > c:\tstlog.txt" %> the batch file is as follows:
5
6062
by: Ian Davies | last post by:
Hello I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your are hosting your site on the same machine you want to copy the files to. Does anyone know if there...
29
3395
by: Tola | last post by:
In my case of study, my teacher gave me a project, after I analysed the problem I found that I had to used open the file on the other machine? Please help? Thank you in advance. Tola CHROUK
1
3895
by: POnfri | last post by:
Hi, I have a problem in a peace of code were i'm doing a file copy using File.Copy. The Source is local and the target is a remote machine. Example: File.Copy(C:\temp\hi.txt, \\myremote\c$\temp\hi.txt, true); This API is run from a web service that exposes it. The problem is as follows: 1) I request a page (On the web service machine) from my web server (Note
1
3021
by: Saracen | last post by:
I have a major problem with trying to access a foxpro database from a web app. I have created a web app which is deployed on a server. The foxpro database (dbf) is on a different server. The access to the database is a shared path. I hace tried everything the only options that seem to work ON THE WEB SERVER ONLY is if I set the impersonate to true in the web.config file. This is fine and works if I access the page using ie on the...
18
4347
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't get it to upload a file to the FTP server. I just get a "Cannot connect to remote server" error after this TRY: s = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
1
8134
by: Duffman | last post by:
Hi, I have what seems to be a common problem, but the solutions I've found don't seem to work. I would like to use a web service to create a file at a UNC location in a shared file. Currently I'm just running it locally and saving the file locally using my machines UNC path. I have given user ASPNET full control over the folder I want to write the file to. I've also tried using the web config identity impersonation to use my user...
5
17756
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager with the path "\\ 192.168.2.2\temp" (where temp is a shared directory on server \\192.168.2.2), windows prompts for a User Name and password of a user who has permission on that computer to access that directory. If I enter valid details, the...
0
8944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9306
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.