The program psexec runs any command remotely on another computer. the syntax is "psexec \\RemoteComputer cmd.exe"
I want to run "start "www.website.com" on computers a19-(01-29)
any help would be appreciated

#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>


using namespace std;

int main(int argc, char *argv[])
{
         int compNum;
         compNum=0;
         std::string zero="0";
         std::string foo,s1,s,s2,s3,s6,s7,s8,s10;
         std::string command;
         
         
////////////////////////////////////////////////////////////////////////


         for (compNum; compNum < 10;compNum++)
               {

std::string compNum2;
std::stringstream out;
out << compNum;
compNum2 = out.str();

//*
                  s1="psexec ";
                  s2= "\\";
                  s3="a19-";
                  s6=" cmd.exe";
                  s7=" '";
                  s8= "start";
                  command = " www.google.com";
                  s10="'";
                  foo = s1 + s2 += s2;
                  foo += s3 += zero;
                  foo += compNum2+= s6 += s7 += s8 += command;
                  foo += s10;
                  cout << foo;
                  cout << "\n";
                  }
                  
///////////////////////////////////////////////////////////////////


for (compNum; compNum < 30;compNum++)
               {

std::string compNum2;
std::stringstream out;
out << compNum;
compNum2 = out.str();

                  s1="psexec ";
                  s2= "\\";
                  s3="a19-";
                  s6=" cmd.exe";
                  s7=" '";
                  s8= "start";
                  command = " www.google.com";
                  s10="'";
                  foo = s1 + s2 += s2;
                  foo += s3;
                  foo += compNum2+= s6 += s7 += s8 += command;
                  foo += s10;
                  cout << foo;
                  cout << "\n";
                  system(foo);
                  
                  }
               

    system("PAUSE");
    return EXIT_SUCCESS;
}

I get these values in the foo variable when I run the program. Is this what should be passed to the system command?

psexec \\a19-00 cmd.exe 'start www.google.com'
psexec \\a19-01 cmd.exe 'start www.google.com'
psexec \\a19-02 cmd.exe 'start www.google.com'
psexec \\a19-03 cmd.exe 'start www.google.com'
psexec \\a19-04 cmd.exe 'start www.google.com'
psexec \\a19-05 cmd.exe 'start www.google.com'
psexec \\a19-06 cmd.exe 'start www.google.com'
psexec \\a19-07 cmd.exe 'start www.google.com'
psexec \\a19-08 cmd.exe 'start www.google.com'
psexec \\a19-09 cmd.exe 'start www.google.com'
psexec \\a19-10 cmd.exe 'start www.google.com'
psexec \\a19-11 cmd.exe 'start www.google.com'
psexec \\a19-12 cmd.exe 'start www.google.com'
psexec \\a19-13 cmd.exe 'start www.google.com'
psexec \\a19-14 cmd.exe 'start www.google.com'
psexec \\a19-15 cmd.exe 'start www.google.com'
psexec \\a19-16 cmd.exe 'start www.google.com'
psexec \\a19-17 cmd.exe 'start www.google.com'
psexec \\a19-18 cmd.exe 'start www.google.com'
psexec \\a19-19 cmd.exe 'start www.google.com'
psexec \\a19-20 cmd.exe 'start www.google.com'
psexec \\a19-21 cmd.exe 'start www.google.com'
psexec \\a19-22 cmd.exe 'start www.google.com'
psexec \\a19-23 cmd.exe 'start www.google.com'
psexec \\a19-24 cmd.exe 'start www.google.com'
psexec \\a19-25 cmd.exe 'start www.google.com'
psexec \\a19-26 cmd.exe 'start www.google.com'

yes... all of those should be sent to cmd

You need to use the /c option on cmd: psexec \\a19-00 cmd /c 'start www.google.com'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.