简体   繁体   中英

Running a batch from a shared drive on a remote network computer

So ultimately what I am trying to do is make it so on my companies network I can execute batch files that are stored on different network drive on a remote computer that will run a installation (batch files are already tested working) I've looked into PsExec with little to nothing to show for it.

My Idea is this

1: I need to install IE9 on a network computer with the hostname of s1roc. 2: I open my application, type my computer name s1roc OR IP into a textbox, select IE9 from a combobox (which is already working) 3: click install, and the batch file stored at s2department\\installs\\install.cmd gets initiated on computer m1roc as if I had remoted in and used the windows run command and entered file://s2department.loc/installs/install.cmd.

I understand this is asking a lot and I'm not asking for all the code to do this I just have 0 idea how to do it to a remote device, I got it down to install it on the local machine just need it now so I can target remote machines for the installation.

Currently I am using this on a local machine but need to be able to target devices with hostnames or at least bare minimum their IP's

        if (XPic.SelectedItem.ToString() == "IE ")
        {
            System.Diagnostics.Process.Start(@"file:\\drive.company.loc\installs\ieinstall.cmd");

The closest thing I got that LOOKS right but doesnt seem to work is this: am I missing something?

string Host; Host = GetHost.Text; System.Diagnostics.Process.Start(@"c:\\PsExec.exe \\\\" +Host+ @" -u Test -p Test \\\\another_remote_pc\\share_with_permissions\\jobs\\job.bat");

I used running remotes tasks through taskmanager and the logon in the past as a software distribution system. You could also use remote desktop or ssh but you were on the easiest track with psexec. Try this

On the remote pc: "activate remote access to your pc" tab "external connections", "external desktop" second option (i'm not sure about the sentences, i'm using a dutch windows here so i translated them).

Make a share on your network that the remote user will have access to (mind the permissions).

Place a simple batch here.

I tested with job.bat which only contains one line You need a remote user on the remote pc which has administrator rights, he MUST have a password.

I named it remote_user_name with password remote_user_password (for testing only).

md c:\testing

Execute the remote job

c:\tools\psexec.exe \\remote-pc -u remote_user_name -p remote_user_password cmd.exe /c \\another_remote_pc\share_with_permissions\jobs\job.bat

There should be a folder c:\\testing on the remote pc. I did test this in a Homegroup using 2 Windows 7 pc's, on a corporate network this shouldn't be a problem (tested it in the past).

After this works you can add more elaborate scripts but mind they don't have prompts, that simply won't work. On the remote you won't see any prompts eather. Success..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM