| | |
trying to run a string as a command
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 6
Reputation:
Solved Threads: 0
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
I want to run "start "www.website.com" on computers a19-(01-29)
any help would be appreciated
C++ Syntax (Toggle Plain Text)
#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; }
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
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'
![]() |
Other Threads in the C++ Forum
- Previous Thread: illegal token for "::"
- Next Thread: problem in makefile
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






