2008年5月16日金曜日

Windowsのプログラムから、リモートへのファイルコピーを行う方法


・Unix系のPCへのファイルコピー

char cmd[256];
sprintf(cmd,"c:\\windows\\system32\\rcp.exe %s hs.yoshida:/tmp",FileName);
int x = system(cmd);
printf("%i=%s\n",x,cmd);

・Windowsへのファイルコピー

sprintf(cmd,"c:\\windows\\system32\\net.exe use \\\\Hostname\\name /USER:user passwd");
x = system(cmd);
printf("%i=%s\n",x,cmd);

sprintf(cmd,"copy %s \\\\Hostname\\name\\path\\",FileName);
x = system(cmd);
printf("%i=%s\n",x,cmd);

sprintf(cmd,"c:\\windows\\system32\\net.exe use \\\\Hostname\\name /DELETE");
x = system(cmd);
printf("%i=%s\n",x,cmd);

0 件のコメント: