- Timestamp:
- Mar 13, 2017 6:57:58 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r65723 r66068 1025 1025 RTStrmPrintf(pStrm, 1026 1026 "%s unattended %s <uuid|vmname>\n" 1027 " usefile --file <file>\n" 1028 " usedata\n" 1027 1029 " --user <username>\n" 1028 1030 " --password <password>\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r65724 r66068 1237 1237 { "-addisopath", 'a', RTGETOPT_REQ_STRING }, 1238 1238 { "-imageindex", 'm', RTGETOPT_REQ_UINT16 }, 1239 { "--imageindex", 'm', RTGETOPT_REQ_UINT16 }, 1239 { "--imageindex", 'm', RTGETOPT_REQ_UINT16 }, 1240 { "-settingfile", 's', RTGETOPT_REQ_STRING }, 1241 { "--settingfile", 's', RTGETOPT_REQ_STRING }, 1240 1242 }; 1241 1243 … … 1252 1254 Bstr machineName; 1253 1255 BOOL bInstallGuestAdditions; 1256 Bstr fileWithSettings; 1254 1257 unsigned short imageIndex = 1;//applied only to Windows installation 1255 1258 … … 1258 1261 RTGETOPTSTATE GetState; 1259 1262 1260 // start at 0 because main() has hacked both the argc and argv given to us1263 // start at 2(third) argument because 0(first) is <uuid\vmname>, 1(second) is <usedata\usefile> 1261 1264 RTGetOptInit(&GetState, a->argc, a->argv, g_aUnattendedInstallOptions, RT_ELEMENTS(g_aUnattendedInstallOptions), 1262 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1263 while ((c = RTGetOpt(&GetState, &ValueUnion))) 1264 { 1265 switch (c) 1266 { 1267 case 'u': // --user 1268 user = ValueUnion.psz; 1269 break; 1270 1271 case 'p': // --password 1272 password = ValueUnion.psz; 1273 break; 1274 1275 case 'k': // --key 1276 productKey = ValueUnion.psz; 1277 break; 1278 1279 case 'a': // --addisopath 1280 vboxAdditionsIsoPath = ValueUnion.psz; 1281 break; 1282 1283 case 'i': // --isopath 1284 isoPath = ValueUnion.psz; 1285 break; 1286 case 'm': // --image index 1287 imageIndex = ValueUnion.u8; 1288 break; 1289 default: 1290 return errorGetOpt(USAGE_UNATTENDEDINSTALL, c, &ValueUnion); 1291 } 1292 } 1293 1294 /* check for required options */ 1295 if (user.isEmpty() || 1296 password.isEmpty() || 1297 isoPath.isEmpty() 1298 ) 1299 return errorSyntax(USAGE_UNATTENDEDINSTALL, "One of needed parameters has been missed"); 1265 2, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 1266 1267 if (!strcmp(a->argv[1], "usefile")) 1268 { 1269 while ((c = RTGetOpt(&GetState, &ValueUnion))) 1270 { 1271 switch (c) 1272 { 1273 case 's': // --a file with data prepared by user 1274 fileWithSettings = ValueUnion.psz; 1275 break; 1276 default: 1277 return errorGetOpt(USAGE_UNATTENDEDINSTALL, c, &ValueUnion); 1278 } 1279 } 1280 1281 /* check for required options */ 1282 if (fileWithSettings.isEmpty()) 1283 return errorSyntax(USAGE_UNATTENDEDINSTALL, "One of needed parameters has been missed"); 1284 } 1285 else if(!strcmp(a->argv[1], "usedata")) 1286 { 1287 while ((c = RTGetOpt(&GetState, &ValueUnion))) 1288 { 1289 switch (c) 1290 { 1291 case 'u': // --user 1292 user = ValueUnion.psz; 1293 break; 1294 1295 case 'p': // --password 1296 password = ValueUnion.psz; 1297 break; 1298 1299 case 'k': // --key 1300 productKey = ValueUnion.psz; 1301 break; 1302 1303 case 'a': // --addisopath 1304 vboxAdditionsIsoPath = ValueUnion.psz; 1305 break; 1306 1307 case 'i': // --isopath 1308 isoPath = ValueUnion.psz; 1309 break; 1310 case 'm': // --image index 1311 imageIndex = ValueUnion.u8; 1312 break; 1313 default: 1314 return errorGetOpt(USAGE_UNATTENDEDINSTALL, c, &ValueUnion); 1315 } 1316 } 1317 1318 /* check for required options */ 1319 if (user.isEmpty() || password.isEmpty() || isoPath.isEmpty()) 1320 return errorSyntax(USAGE_UNATTENDEDINSTALL, "One of needed parameters has been missed"); 1321 } 1322 else 1323 { 1324 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Unknown subcommand. Must be \"usefile\" or \"usedata\" "); 1325 } 1300 1326 1301 1327 /* try to find the given machine */ … … 1336 1362 CHECK_ERROR_BREAK(machine, COMGETTER(Unattended)(unAttended.asOutParam())); 1337 1363 1338 CHECK_ERROR_BREAK(unAttended, COMSETTER(Group)(group.raw())); 1339 1340 if (installedOSStr.contains("Windows") && productKey.isEmpty()) 1341 { 1342 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Product key has been missed."); 1343 } 1344 1345 CHECK_ERROR_BREAK(unAttended, COMSETTER(VboxAdditionsIsoPath)(vboxAdditionsIsoPath.raw())); 1346 1347 CHECK_ERROR_BREAK(unAttended, COMSETTER(IsoPath)(isoPath.raw())); 1348 1349 CHECK_ERROR_BREAK(unAttended, COMSETTER(User)(user.raw())); 1350 1351 CHECK_ERROR_BREAK(unAttended, COMSETTER(Password)(password.raw())); 1352 1353 CHECK_ERROR_BREAK(unAttended, COMSETTER(ProductKey)(productKey.raw())); 1354 1355 bool fInstallGuestAdditions = (vboxAdditionsIsoPath.isEmpty()) ? false: true; 1356 CHECK_ERROR_BREAK(unAttended, COMSETTER(InstallGuestAdditions)(fInstallGuestAdditions)); 1357 1358 CHECK_ERROR_BREAK(unAttended, COMSETTER(ImageIndex)(imageIndex)); 1359 1360 CHECK_ERROR_BREAK(unAttended,Preparation()); 1361 CHECK_ERROR_BREAK(unAttended,ConstructScript()); 1362 CHECK_ERROR_BREAK(unAttended,ConstructMedia()); 1363 CHECK_ERROR_BREAK(unAttended,ReconstructVM()); 1364 CHECK_ERROR_BREAK(unAttended,RunInstallation()); 1364 if (fileWithSettings.isEmpty())//may use also this condition (!strcmp(a->argv[1], "usedata")) 1365 { 1366 CHECK_ERROR_BREAK(unAttended, COMSETTER(Group)(group.raw())); 1367 1368 if (installedOSStr.contains("Windows") && productKey.isEmpty()) 1369 { 1370 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Product key has been missed."); 1371 } 1372 1373 CHECK_ERROR_BREAK(unAttended, COMSETTER(VboxAdditionsIsoPath)(vboxAdditionsIsoPath.raw())); 1374 1375 CHECK_ERROR_BREAK(unAttended, COMSETTER(IsoPath)(isoPath.raw())); 1376 1377 CHECK_ERROR_BREAK(unAttended, COMSETTER(User)(user.raw())); 1378 1379 CHECK_ERROR_BREAK(unAttended, COMSETTER(Password)(password.raw())); 1380 1381 CHECK_ERROR_BREAK(unAttended, COMSETTER(ProductKey)(productKey.raw())); 1382 1383 bool fInstallGuestAdditions = (vboxAdditionsIsoPath.isEmpty()) ? false: true; 1384 CHECK_ERROR_BREAK(unAttended, COMSETTER(InstallGuestAdditions)(fInstallGuestAdditions)); 1385 1386 CHECK_ERROR_BREAK(unAttended, COMSETTER(ImageIndex)(imageIndex)); 1387 CHECK_ERROR_BREAK(unAttended,Preparation()); 1388 CHECK_ERROR_BREAK(unAttended,ConstructScript()); 1389 CHECK_ERROR_BREAK(unAttended,ConstructMedia()); 1390 CHECK_ERROR_BREAK(unAttended,ReconstructVM()); 1391 CHECK_ERROR_BREAK(unAttended,RunInstallation()); 1392 1393 } 1394 else 1395 { 1396 CHECK_ERROR_BREAK(unAttended, COMSETTER(FileWithPreparedData)(fileWithSettings.raw())); 1397 CHECK_ERROR_BREAK(unAttended,Preparation()); 1398 CHECK_ERROR_BREAK(unAttended,ReconstructVM()); 1399 CHECK_ERROR_BREAK(unAttended,RunInstallation()); 1400 } 1401 1365 1402 a->session->UnlockMachine(); 1366 // CHECK_ERROR_RET(sessionMachine, UnlockMachine(), RTEXITCODE_FAILURE); 1403 1367 1404 { 1368 1405 Bstr env; … … 1421 1458 bInstallGuestAdditions = false; 1422 1459 imageIndex = 0; 1423 1460 fileWithSettings.setNull(); 1461 1462 CHECK_ERROR_BREAK(unAttended, COMGETTER(FileWithPreparedData)(fileWithSettings.asOutParam())); 1424 1463 CHECK_ERROR_BREAK(unAttended, COMGETTER(Group)(group.asOutParam())); 1425 1464 CHECK_ERROR_BREAK(unAttended, COMGETTER(VboxAdditionsIsoPath)(vboxAdditionsIsoPath.asOutParam())); … … 1429 1468 CHECK_ERROR_BREAK(unAttended, COMGETTER(ProductKey)(productKey.asOutParam())); 1430 1469 CHECK_ERROR_BREAK(unAttended, COMGETTER(ImageIndex)(&imageIndex)); 1431 RTPrintf("Got values:\n user: %s\n password: %s\n productKey: %s\n image index: %d\n "1470 RTPrintf("Got values:\n fileWithSettings: %s\n user: %s\n password: %s\n productKey: %s\n image index: %d\n " 1432 1471 "isoPath: %s\n vboxAdditionsIsoPath: %s\n", 1472 Utf8Str(fileWithSettings).c_str(), 1433 1473 Utf8Str(user).c_str(), 1434 1474 Utf8Str(password).c_str(),
Note:
See TracChangeset
for help on using the changeset viewer.