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$\app l" 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.Win 32Exceptio n: Access is Denied"
Here is the batch file:
@echo off
set PFDSK=\\servername\c$\appl \filepro
set PFDATA=\\servername\c$\app l
set PFPROG=\\servername\c$\app l
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.SecureStri ng
Dim pwd As String = "********"
Array.ForEach(pwd.ToCharAr ray(), AddressOf spwd.AppendChar)
fp.StartInfo.Password = spwd
fp.StartInfo.FileName = "\\servername\c$\FP_Logins \User_Upda te.bat
fp.StartInfo.UseShellExecu te = False
fp.StartInfo.CreateNoWindo w = False
fp.Start() '<<<Fails here>>>
End Sub
The batch file is setup to use paths such as "set PFDATA=\\servername\c$\app
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.Win
Here is the batch file:
@echo off
set PFDSK=\\servername\c$\appl
set PFDATA=\\servername\c$\app
set PFPROG=\\servername\c$\app
set PFDIR=
set PFMENU=\\servername\c$\fp\
set PFGLOB=
set PFCONFIG=
set PATH=%pfprog%;%PFPROG%\fp;
%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
Dim spwd As New System.Security.SecureStri
Dim pwd As String = "********"
Array.ForEach(pwd.ToCharAr
fp.StartInfo.Password = spwd
fp.StartInfo.FileName = "\\servername\c$\FP_Logins
fp.StartInfo.UseShellExecu
fp.StartInfo.CreateNoWindo
fp.Start() '<<<Fails here>>>
End Sub
Though the solution im providing here is not linked to vb.net - but for remote file execution i used psexec.exe from sysinternals
ASKER
Running psexec.exe in VB.net still requires a domain admin login to run "\\servername\c$\FP_Logins \User_Upda te.bat as the .NET service acct that VB.NET runs under doesn't have the rights.
ASKER
Is there any rights for a domain user I can setup in order for that user to access \\servername\c$\FP_Logins\ User_Updat e.bat"
???
???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.