blackadder has asked for the wisdom of the Perl Monks concerning the following question:

Greetings divine beings

I have this command which installs printer definitions system qw[ cmd.exe /c start \\\\oywps01\\snp109 ]; And I need to run it on 2500 Windows XP Machines!

I read and tested the code of everything on this site that has the word remote cmd, process, executing remote command…etc you name it I tried it and it did not work!

Can someone please tell me how can I run this command on those machines remotely and successfully

Thanking You

Blackadder

20041011 Edit by castaway: Changed title from 'executing a command on a remote Windows XP machine'

Replies are listed 'Best First'.
Re: (OT) executing a command on a remote Windows XP machine
by NetWallah (Canon) on Oct 06, 2004 at 17:11 UTC
    What you need is psexec.

    "PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems. "

        Earth first! (We'll rob the other planets later)

      Yeah That works

      But, why can't a pure perl solution do the same!

      Thanks very much.
Re: (OT) executing a command on a remote Windows XP machine
by tachyon (Chancellor) on Oct 07, 2004 at 00:37 UTC

    If you have 2500 machines on a network prsumably you have Active Directory. All you need to do is add a logon script to your GPO I would have thought. See this tutorial There are many ways to execute things remotely. M$ turns them off progrssively as people exploit them. For example if you tried my Win32::KillProcess module it may or may not have worked depending on the availability of certain scripting features which are now ? disabled by default ? Given you comments about how hard it is to install Perl modules on Win32 (it is not, you simply need to know how) I would wonder if you are using the tools you have available correctly. When all else fails read the instructions ;-)

    @echo off \\oywps01\snp109

    cheers

    tachyon

      Thanks for enlightenment

      God Bless You.
      Hi Ya,

      Yes we do, but its in NewYork and I am in a DR site here in London. I have no chance of accessing the AD or doing any thing with it.

      So I used this code
      use Win32::KillProcess qw( connectServer startProcess ); $server="SN02GEV14A"; $user="MOD\Blackadder_sup"; $pass="Perlmonks2004"; my $c = connectServer( $server, $user, $pass ); startProcess( $c, "cmd.exe /c start \\\\oywps01\\snp104");
      And I am getting this error
      C:\Perl>proc_start.pl Can't access WMI on remote machine SN02GEV14A: OLE exception from "SWb +emLocator": Access is denied. Win32::OLE(0.1701) error 0x80070005: "Access is denied" in METHOD/PROPERTYGET "ConnectServer" at C:/Perl/site/lib/Win32/Ki +llProcess.pm line 30.
      I posted the above on another thread in answer to how to install WIn32::KillProcess, But will continoue with this thread from now on to avoid duplication.

      Thanks
      Blackadder

        Which part of 'Access Denied' is confusing you ;-) You need to use a valid username and password.

        $user="DOM\username" # bound to fail $user="DOM\\username" # OK $user='DOM\username' # OK as well

        Once you fix that tt should work as the SWbemLocator you need running remotely provided that error. You do need valid credentials though. This works fine for me:

        use Win32::KillProcess ':all'; my $server = "Toshiba"; my $user = "WORKGROUP\\Administrator"; my $pass = "password"; my $c = connectServer( $server, $user, $pass ); showRunningProcess($c);

        cheers

        tachyon

Re: (OT) executing a command on a remote Windows XP machine
by BrowserUk (Patriarch) on Oct 06, 2004 at 19:38 UTC

    Does the command you show work from the command line?

    I doubt it, as the way you have it coded, it would try to load the command snp109 from the remote machine \\oywps01 and run it on the local machine.

    Once you have worked out the correct syntax for running the command on the remote machine from the command line, that same syntax will probably work from your script via system.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      Oh yeah it does buddy,....

      its only a print server with few printer defenistion on'em.

      I am using PSEXEC utilty to do the job,..But I will try WIn32::KillProcess again, I'd much rather a Perl solution than any other.
      Blackadder