Link to home
Start Free TrialLog in
Avatar of shelbyinfotech
shelbyinfotech

asked on

Run a batch file on a remote Windows 2003 server

I have a stand alone windows VB.NET application on a Windows XP machine that I'm trying to get to run a batch file on a remote server.  I'm using system.diagnostics.start to run the batch file.

The batch file is setup to use paths such as "set PFDATA=\\servername\c$\appl" etc.
I've setup a service acct of "filepro" to use when running the VB.NET application.

If I give "filepro" Domain Admin rights, then the application runs the batch file.  However, I don't want to give "filepro" Domain Admin rights.  I'd like to give him Domain User rights and then modify the folder's share/security permissions on the W2K3 server.

I don't want to use mapped drives due to the fact that if the application crashes, the mapped drives won't be disconnected from the users computer.

I've shared, and given "filepro" full control over the paths in the batch file plus the "\\servername\c$\windows" folder (for cmd.exe ?).

The program fails with a "System.ComponentModel.Win32Exception: Access is Denied"

Here is the batch file:

@echo off
set PFDSK=\\servername\c$\appl\filepro
set PFDATA=\\servername\c$\appl
set PFPROG=\\servername\c$\appl
set PFDIR=
set PFMENU=\\servername\c$\fp\menus
set PFGLOB=
set PFCONFIG=
set PATH=%pfprog%;%PFPROG%\fp;%path%
%pfprog%\fp\p AVD01


And here is the applicable portion of the .net application:

Private Sub StartBtn_Click ...
Dim fp As Diagnostics.Process = New Diagnostics.Process
fp.StartInfo.UserName = "filepro"
fp.StartInfo.Domain = Environment.UserDomainName.ToString
Dim spwd As New System.Security.SecureString
Dim pwd As String = "********"
        Array.ForEach(pwd.ToCharArray(), AddressOf spwd.AppendChar)
        fp.StartInfo.Password = spwd
fp.StartInfo.FileName = "\\servername\c$\FP_Logins\User_Update.bat
fp.StartInfo.UseShellExecute = False
fp.StartInfo.CreateNoWindow = False

fp.Start()   '<<<Fails here>>>
End Sub
Avatar of kishoreb123
kishoreb123

Though the solution im providing here is not linked to vb.net - but for remote file execution i used psexec.exe from sysinternals
Avatar of shelbyinfotech

ASKER

Running psexec.exe in VB.net still requires a domain admin login to run "\\servername\c$\FP_Logins\User_Update.bat as the .NET service acct that VB.NET runs under doesn't have the rights.
Is there any rights for a domain user I can setup in order for that user to access \\servername\c$\FP_Logins\User_Update.bat"
???
ASKER CERTIFIED SOLUTION
Avatar of shelbyinfotech
shelbyinfotech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial