You are on page 1of 12

Using vmrun to Control Virtual Machines

For VMware Workstation 6.5 and VMware Server 2.0

Using vmrun to Control Virtual Machines

Using vmrun to Control Virtual Machines Revision: 20080815 Item: EN-000068-00

You can find the most up-to-date technical documentation on our Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com

2008 VMware, Inc. All rights reserved. Protected by one or more U.S. Patent Nos. 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145, 7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815, 7,260,820, 7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030, 7,281,102, 7,290,253, 7,356,679, 7,409,487, 7,412,492, and 7,412,702; patents pending. VMware, the VMware boxes logo and design, Virtual SMP and VMotion are registered trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.

VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com

VMware, Inc.

About This Book

Thismanual,UsingvmruntoControlVirtualMachines,introducesthevmruncommand,aconvenientcommand tohelpyoumanagethecollectionofvirtualmachinesonaVMwarehost.

Revision History
Thisbookisrevisedwitheachreleaseoftheproductorwhennecessary.Arevisedversioncancontainminor ormajorchanges.Table 1summarizesthesignificantchangesineachversionofthisguide. Table 1. Revision History
Revision 20080623 20080815 Description FirstdraftofthismanualfortheVMwareServer2.0RC1andWorkstation6.5Beta2releases. ThirddraftfortheVMwareServer2.0RC2andWorkstation6.5RCreleases.

Intended Audience
Thisbookisintendedfordevelopersandsystemadministratorswhowanttocontrolvirtualmachineson variousplatforms,includingVMwareWorkstation,VMwareFusion,andVMwareServer.

API and SDK Documentation


VMwareprovidesmanydifferentproductstargetingdifferentdevelopercommunitiesandplatforms.Forthe mostuptodateinformationaboutAPIandSDKproducts,thisistheplacetogo: http://www.vmware.com/support/pubs/sdk_pubs.html

Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Sendyourcommentsto: docfeedback@vmware.com

Technical Support and Education Resources


Thefollowingsectionsdescribethetechnicalsupportresourcesavailabletoyou.Youcanaccessthemost currentversionsofotherVMwaremanualsbygoingto: http://www.vmware.com/support/pubs

Online Support
YoucansubmitquestionsorpostcommentstotheDeveloperCommunity:SDKsandAPIsforum,whichthe VMwaretechnicalsupportandproductteamsmonitor.Youcanaccesstheforumat: http://communities.vmware.com/community/developer
VMware, Inc. 3

Using vmrun to Control Virtual Machines

Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto: http://www.vmware.com/support/services

VMware Education Services


VMwarecoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerialsdesignedtobeused asonthejobreferencetools.FormoreinformationaboutVMwareEducationServices,goto: http://mylearn1.vmware.com/mgrreg/index.cfm

VMware, Inc.

Using vmrun to Control Virtual Machines

VMwareprovidesanapplicationcalledvmrunforcontrollingvirtualmachines,orteamsofvirtualmachines, fromthecommandline.ThevmruncommandisavailableonanyVMwareproductthatincludestheVIXAPI libraries,orwhenthelibrariesareseparatelyinstalled.Thischaptercontainsthefollowingsections: AboutthevmrunCommand,below. UsingvmrunonWindowsonpage 6 UsingvmrunonLinuxonpage 6. VirtualMachineRunFlagsonpage 7. VirtualMachineRunCommandsonpage 7. ExamplesofUsingvmrunonpage 11.

About the vmrun Command


ThevmruncommandmanipulatesvirtualmachinesandrunsonanyVMwareplatformwhereyoucaninstall theVIXlibraries,includingVMwareWorkstationandVMwareServer.Forinformationaboutthefacilitiesthat vmruncontrols,seethedocumentationforyourproduct,suchastheUsersManual. Thisdocumentorganizesvmruncommandsintothesixfollowingcategories.

Power Commands
Virtualmachinepoweroperationsgiveyoutheseoptions:start(poweron),stop(poweroff),reset(reboot), suspend(butallowlocalworktoresume),pause(withoutinterrupting),andunpause(continue). Onsomeproducts,youcangroupvirtualmachinesintoteams,sopoweroperationsapplytothewholeteam.

Snapshot Commands
Asnapshotreproducesvirtualmachinestateatthetimeofthesnapshot,includingalldataonvirtualdisks. Youcansnapshotavirtualmachineasyouchoose,inanypowerstate,andreverttothesnapshotatanytime. Snapshotsareusefulforexperimentation,andespeciallyusefulforbackups. Thesecommandslistexistingsnapshotsofavirtualmachine,createanewsnapshot,deleteasnapshot,and revertavirtualmachinetoitsstateasofaspecificsnapshot.VMwareServerlimitsyoutoonesnapshot.

Record and Replay Commands


Virtualmachineeventscanberecordedforlaterreplay.Therecordingiscalledasnapshotobject,butisreally morelikeamovie.Atthistime,onlyVMwareWorkstationsupportsrecordandreplay. Thesecommandsbeginorendtherecordingofevents,andbeginorendthereplayofarecording.

VMware, Inc.

Using vmrun to Control Virtual Machines

Guest Operating System Commands


Thesearethemostdistinctiveandusefulinterfacesinthevmruncommand.Youcan: Runanexecutableprogramintheguestoperatingsystem,orrunaninterpretedscript.Theseinterfaces serveasimilarpurpose,butrunProgramInGuestprovidesmorefinegrainedcontrol. Checkifafileexistsintheguest,deleteafile,renameafile,listfiles,andcreateordeleteadirectory. Copyafilefromthehosttotheguest,orcopyafilefromtheguesttothehost. Addasharedfolderfromthehost,makeasharedfolderwritableintheguest,removeasharedfolder,or captureascreenimagefromtheguest(exceptonVMwareServer). Listtheprocessesrunningintheguestoperatingsystem,orterminateanyprocess(withpermission). Readorwriteavariableintotheguestoperatingsystemsenvironmentorvirtualmachinestate.

General Commands
Thiscatchallcategoryincludescommandstolistallrunningvirtualmachines,upgradethevirtualmachine hardwareversion,andinstallVMwareToolsontheguest. Additionally,exceptonVMwareServeryoucancloneanyvirtualmachineimagetoanothervirtualmachine. VMwareServerallowsyoutoregisterandunregistervirtualmachines.

VProbes Commands
ThesecommandssupportVProbes,afacilityfordynamicallyandstaticallyinstrumentingportionsof VMwaresoftwareandarunningguestoperatingsystem.SeetheVProbesProgrammingReferencefordetails.

Using vmrun on Windows


TousethevmruncommandonaWindowssystem: 1 Locatethevmrunprogram,whichbydefaultisinstalledhere:
C:\Program Files\VMware\VMware VIX

Addtheinstalllocationtoyoursystempath.OnWindowsXPforexample,choose: Computer>Properties>Advanced>EnvironmentVariables>Systemvariables>Path>Edit Usingtherightarrowkey,movetheinputpointertotheendofline,addasemicolon,thesoftwarelocation path(asinstep1)andclickOKseveraltimes. IfVMwareWorkstationisalreadyinPath,thisstepisoptionalbecauseanothervmrunisinstalledthere.

Inacommandwindow,typethevmruncommandinthefollowingform
vmrun <flags> <command> <parameters>

ContinuewithVirtualMachineRunFlagsonpage 7.

Using vmrun on Linux


TousethevmruncommandonaUNIXsystem: 1 (Optional)Asrootorsuperuser,editthe/etc/ld.so.conffile,addalinewiththelibrarylocation defaultdirectorybelow,savethefile,andruntheldconfigcommand.
/usr/lib/vmware-vix/lib

Inacommandorterminalwindow,typethevmruncommandinthefollowingform
vmrun <flags> <command> <parameters>

ContinuewithVirtualMachineRunFlagsonpage 7.

VMware, Inc.

Using vmrun to Control Virtual Machines

Virtual Machine Run Flags


OnVMwareWorkstation,vmruncontrolsguestoperatingsystemsonthelocalhost,soyouneednotspecifya remotehostnameorport.Possiblynoflagsarerequired. Inthesyntaxexamplesbelow,flagsenclosedinanglebracketsindicatevariablesthatyoufillin. Forcommandsthatrequireauthenticationbytheguestoperatingsystem,thecommanddescriptionstates validguestloginrequired,inwhichcaseyoumustusethefollowingflags:
-gu <userName in guest OS> -gp <userPassword in guest OS>

TosetthehosttypeforremoteaccesstoVMwareServer2.0,usethefollowingflagsinconjunction:
-T -h -P -u -p server <hostName> <portNumber> <adminLogin on Server> <adminPassword on Server>

Forexample,thiscommandlistsallrunningvirtualmachinesonaremoteserver:
vmrun -T server -h https://example.com/sdk -u root -p secretpw list

ForVMwareWorkstation,usetheTflagasfollows:
vmrun -T ws

ForVMwareServer1.0,usetheTflagasfollows:
vmrun -T server1

NOTEOnVMwareWorkstation,startingavirtualmachinewiththedefaultguioptionrequiresawindow systemtoberunningonthehost.VMwareServerdoesnotimposethisrequirement. VMwareServerdoesnotsupportteams,sharedfolders,cloning,recordandreplay,ormultiplesnapshots. Whenyoutrytocreateasecondsnapshot,theUIasksifyouwanttooverwriteyourexistingsnapshot.

Virtual Machine Run Commands


VMwarestoresvirtualmachinesasapackageincludingthevirtualmachinesettingsfile(<vnname>.vmx)and thevirtualdisks.Whenrequired,youmustgivevmrunthecompletepathtothe.vmxfile.Herearesome examplesofwherethe.vmxfilemightbelocated: OnWindows pathonVMwareWorkstation:
C:\Documents and Settings\<username>\My Documents\My Virtual Machines\Win XP\Win XP.vmx

datastoreonVMwareServer:
[storage1]Win XP/Win XP.vmx

OnLinux pathonVMwareWorkstation:
/home/<username>/VirtualMachines/Ubuntu/Ubuntu.vmx

datastoreonVMwareServer:
[storage1]Win XP/Win XP.vmx

AllthevmruncommandsandparametersaregroupedanddocumentedinTable 2.Parametersarelistedone perline.Parametersenclosedinsquarebracketsareoptional.Theverticalbarindicatesakeywordchoice.

VMware, Inc.

Using vmrun to Control Virtual Machines

Table 2. vmrun Commands and Parameters


Command Power Commands start (Teamsnotsupportedon VMwareServer.) Startavirtualmachine(.vmxfile)orteam(.vmtmfile). Thedefaultguioptionstartsinteractively,whichis requiredtodisplayaWorkstationuserinterface.The noguioptionsuppressestheuserinterface,including startupdialogbox,toallownoninteractivescripting. Stopavirtualmachine(.vmxfile)orteam(.vmtmfile). Usethesoftparametertopowerofftheguestafter runningshutdownscripts.Usethehardparameterto powerofftheguestwithoutrunningscripts,asifyou pressedthepowerbutton.Thedefaultistostopusing thepowerTypespecifiedinthe.vmxfile,ifpresent. Resetavirtualmachine(.vmxfile)orteam(.vmtmfile). Usethesoftparametertorunshutdownscriptsbefore rebootingtheguest.Usethehardparametertoreboot theguestwithoutrunningscripts,asifyoupressedthe resetbutton.ThedefaultistoresetusingthepowerType specifiedinthe.vmxfile,ifpresent. Suspendavirtualmachine(.vmxfile)orteam(.vmtm) withoutshuttingdown,solocalworkcanresumelater. Thesoftparametersuspendstheguestafterrunning systemscripts.OnWindowsguests,thesescriptsrelease theIPaddress,whileonUNIXgueststheysuspend networking.Thehardparametersuspendstheguest withoutrunningthesescripts.Thedefaultistosuspend usingpowerTypespecifiedinthe.vmxfile,ifpresent. Toresumevirtualmachineoperationaftersuspend,use thestartcommand.OnWindowstheIPaddressis retrievedandonLinuxnetworkingisrestarted. pause unpause Snapshot Commands listSnapshots snapshot (VMwareServerdoesnot supportmultiplesnapshots.) Listallsnapshotsinavirtualmachine(.vmxfile). Createasnapshotofavirtualmachine(.vmxfile).For productssuchasWorkstationthatsupportmultiple snapshots,youmustprovidethesnapshotname. Becausetheforwardslashdefinespathnames,VMware recommendsthatyouavoidusingtheslashcharacter whennamingasnapshot,becausethatmakesitdifficult tospecifythesnapshotpathprecisely. deleteSnapshot (VMwareServeralways deletestherootsnapshot.) Removeasnapshotfromavirtualmachine(.vmxfile). ForproductssuchasWorkstationthatsupportmultiple snapshots,youmustprovidethesnapshotname. Thevirtualmachinemustbepoweredofforsuspended. Ifthissnapshothaschildren,theybecomechildrenof thedeletedsnapshotsparentandsubsequentsnapshots continueasbeforefromtheendofchain. <pathto.vmxfile> <snapshotname> <pathto.vmxfile> <pathto.vmxfile> <snapshotname> Pauseavirtualmachine(.vmxfile).Thisisusedtopause replay,butcanbeusedinothercontexts. Unpauseavirtualmachine(.vmxfile)andresume operationwhereitpaused. <pathto.vmxfile> <pathto.vmxfile> <pathto.vmxor.vmtmfile> [gui|nogui] Description Parameters

stop (Teamsnotsupportedon VMwareServer.)

<pathto.vmxor.vmtmfile> [hard|soft]

reset (Teamsnotsupportedon VMwareServer.)

<pathto.vmxor.vmtmfile> [hard|soft]

suspend (Teamsnotsupportedon VMwareServer.)

<pathto.vmxor.vmtmfile> [hard|soft]

VMware, Inc.

Using vmrun to Control Virtual Machines

Table 2. vmrun Commands and Parameters (Continued)


Command revertToSnapshot (VMwareServeralways revertstotherootsnapshot.) Description Setthevirtualmachinestatetoasnapshot. Ifasnapshothasauniquenamewithinavirtual machine,reverttothatsnapshotbyspecifyingthepath tothevirtualmachinesconfigurationfileandthe snapshotname(firstgroupofparameters). Ifseveralsnapshotshavethesamename,youcanstill specifythesnapshotbyincludingapathnameforthe snapshotname.Apathnameisaseriesofsnapshot names,separatedbyforwardslashcharacters(/).Each namespecifiesadifferentsnapshotinthetree.For example,thepathnameSnap1/Snap2identifiesa snapshotnamedSnap2thatwastakenfromthestateof arootsnapshotnamedSnap1. Record and Replay Commands beginRecording (Recordingnotsupportedon VMwareServer.) endRecording beginReplay (Replaynotsupportedon VMwareServer.) endReplay Beginrecordingarunningvirtualmachine(.vmxfile), storingactivityinthespecifiedsnapshotobject,with optionaldescription. Onlyonerecordingorreplaycanbeactiveatatime. Endtherecordingofavirtualmachine(.vmxfile)thatis inprogress,andcloseitssnapshotobject. Beginreplayingtherecordedactivityofapoweredoff virtualmachine(.vmxfile)fromasnapshotobject. Onlyonerecordingorreplaycanbeactiveatatime. Endthereplayingofavirtualmachine(.vmxfile)thatis currentlyunderway. <pathto.vmxfile> <pathto.vmxfile> <snapshotobjectname> [<description>] <pathto.vmxfile> <pathto.vmxfile> <snapshotobjectname> Parameters <pathto.vmxfile> <snapshotname> or <pathto.vmxfile> <snap1/snap2/snapN>

Guest Operating System Commands runProgramInGuest Runaprogramintheguestoperatingsystem.Provide thefullpathnameofaprogramaccessibletotheguest. VMwareToolsandvalidguestloginarerequired. Alsoprovidefullaccessiblepathnamesforanyfiles specifiedintheprogramarguments. The-noWaitoptionmeanstoreturnimmediatelyafter theprogramstartsintheguest,ratherthanwaitingforit tofinish.Thisisusefulforinteractiveprograms. The-activeWindowflagensuresthattheWindowsGUI isvisible,notminimized.IthasnoeffectonLinux. The-interactiveflagforcesinteractiveguestlogin andisusefulforWindowsVistaguests,tomakethe programvisibleintheconsolewindow. fileExistsInGuest Checkwhetherthespecifiedfileexistsintheguest operatingsystem.VMwareToolsandvalidguestlogin arerequired. Modifythewriteabilitystateofafoldersharedbetween thehostandaguestvirtualmachine(.vmxfile). Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. Asharedfoldercanbemadewritableorreadonly. Addafoldertobesharedbetweenthehostandguest. Thesharenameisamountpointintheguestfilesystem. Thepathtofolderistheexporteddirectoryonthehost. Removeaguestvirtualmachinesaccesstoashared folderonthehost.Thesharenameisamountpointin theguestfilesystem. Listallprocessesrunningintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. <pathto.vmxfile> <pathtofileinguest> <pathto.vmxfile> <sharename> <pathtofolderonhost> writable|readonly <pathto.vmxfile> <sharename> <pathtofolderonhost> <pathto.vmxfile> <sharename> <pathto.vmxfile> <pathto.vmxfile> [-noWait| -activeWindow| -interactive] <programname> [<programarguments>]

setSharedFolderState (VMwareServerdoesnot supportsharedfolders.)

addSharedFolder (VMwareServerdoesnot supportsharedfolders.) removeSharedFolder (VMwareServerdoesnot supportsharedfolders.) listProcessesInGuest

VMware, Inc.

Using vmrun to Control Virtual Machines

Table 2. vmrun Commands and Parameters (Continued)


Command killProcessInGuest Description Stopthespecifiedprocessintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. TakeprocessIDfromthenumberlistedafterpid=inthe outputoflistProcessesInGuest. runScriptInGuest Runacommandscriptintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Theinterpreterpathisthecommandthatrunthescript. Givethecompletetextofthescript,notafilename. deleteFileInGuest Deletethespecifiedfilefromtheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Createspecifieddirectoryintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Deleteadirectoryfromtheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Listdirectorycontentsintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Copyafilefromthehosttotheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Specifysourcefile(host)beforedestinationfile(guest). copyFileFromGuestToHost Copyafilefromtheguestoperatingsystemtothehost. VMwareToolsandvalidguestloginarerequired. Specifysourcefile(guest)beforedestinationfile(host). renameFileInGuest Renameormoveafileintheguestoperatingsystem. VMwareToolsandvalidguestloginarerequired. Specifysourcename(original)beforedestination(new). captureScreen Capturethescreenofthevirtualmachinetoalocalfile. ThespecifiedoutputfileonthehostisinPNGformat. Avalidguestloginisrequired. writeVariable Writeavariableintothevirtualmachinestateorguest. Youcanseteitherruntimeconfigurationinthe.vmxfile, orenvironmentvariablesintheguestoperatingsystem. ThelatterrequiresVMwareToolsandvalidguestlogin. Providethevariablenameanditsvalue. Readavariablefromthevirtualmachinestateorguest. Youcangeteitherruntimeconfigurationinthe.vmxfile, orenvironmentvariablesintheguestoperatingsystem. Thelatterrequiresvalidguestlogin. <pathto.vmxfile> [runtimeConfig|guestEnv] <variablename> <variablevalue> <pathto.vmxfile> [runtimeConfig|guestEnv] <variablename> <pathto.vmxfile> <interpreterpath> <scripttext> <pathto.vmxfile> <pathtofileonguest> <pathto.vmxfile> <directorypathonguest> <pathto.vmxfile> <directorypathonguest> <pathto.vmxfile> <directorypathonguest> <pathto.vmxfile> <filepathonhost> <filepathinguest> <pathto.vmxfile> <filepathinguest> <filepathonhost> <pathto.vmxfile> <originalfilename> <newfilename> <pathto.vmxfile> <outputpathonhost> Parameters <pathto.vmxfile> <processID>

createDirectoryInGuest

deleteDirectoryInGuest

listDirectoryInGuest

copyFileFromHostToGuest

readVariable

General Commands list upgradevm installtools Listallrunningvirtualmachines. Upgradeavirtualmachinetothecurrentversionof virtualhardware.Hasnoeffectifalreadycurrent. PreparetoinstallVMwareToolsintheguestoperating system.InWindowsguestswithautorunenabled,the VMwareToolsinstallerstartsbyitself.InLinuxguests withoutautorun,thiscommandconnectsthevirtual CDROMdrivetotheVMwareToolsISOimagesuitable fortheguest,buttheinstallerdoesnotstart,soyoumust completetheinstallationwithadditionalmanualsteps, asdescribedinyourproductdocumentation. None <pathto.vmxfile> <pathto.vmxfile>

10

VMware, Inc.

Using vmrun to Control Virtual Machines

Table 2. vmrun Commands and Parameters (Continued)


Command register (Registrationnotsupported onVMwareWorkstation.) unregister (Registrationnotsupported onVMwareWorkstation.) clone (Cloningnotsupportedon VMwareServer.) Description Registeravirtualmachine(.vmxfile),addingittothe hostsinventory.Pathformatdependsontheproduct. ForVMwareServer2.0,[storage1]vm/vm.vmx (startingwithdatastore)istypical. Unregisteravirtualmachine(.vmxfile),removingit fromthehostsinventory.Pathformatdependsonthe product.ForServer2.0,[storage1]vm/vm.vmx (startingwithdatastore)istypical. Createacopyofthevirtualmachineandguestoperating system.Providethesource.vmxfilepathname,andthe destination.vmxfilepathname.Youcancreateeithera normalfullclone,oralinkedclone.Ifyouwantto maketheclonefromthissnapshot,ratherthanfromthe currentvirtualmachinestate,specifyasnapshotname. Parameters <pathto.vmxfile>

<pathto.vmxfile>

<pathto.vmxfile> <destination.vmxfilepath> full|linked [<snapshotname>]

VProbes Commands (VMwareServerdoesnot supportVProbes.) vprobeVersion vprobeLoad ShowVProbesversion. LoadVProbesscript. DisableallVProbes. ListactiveVProbes. ListVProbesglobalvariables. <pathto.vmxfile> <pathto.vmxfile> <textofVProbesscript> vprobeReset vprobeListProbes vprobeListGlobals <pathto.vmxfile> <pathto.vmxfile> <pathto.vmxfile>

Examples of Using vmrun


MostexamplesworkonanyeitherVMwareWorkstation.The-Twsand-Tfusionoptionsaresynonymous. Youcanderivetheguestoperatingsystemtypeinexamplesbydistinguishing/forLinuxand\forWindows.

New Examples
StartanXterminalonaLinuxguest(requires-displayoptiontoappearontheconsole):
vmrun -gu <user> -gp <password> runProgramInGuest Ubuntu/Ubuntu.vmx /usr/bin/xterm "-display :0"

ListprocessesinaLinuxguestonWorkstation,andkilltheprocessnumbered20001:
vmrun -T ws -gu guestUser -gp guestPassword listProcessesInGuest Ubuntu/Ubuntu.vmx vmrun -T ws -gu guestUser -gp guestPassword killProcessesInGuest Ubuntu/Ubuntu.vmx 20001

RunabatchscriptonaWindowsguestusingWorkstation:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest WinXP.vmx "C:\Workarea\script.bat"

RunacommandscriptonaWindowsguestusingWorkstation:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest WinXP.vmx C:\Windows\System32\cmd.exe "/c C:\Workarea\script.cmd"

RunaPerlscriptinaLinuxguesttoremoveDOSstylecarriagereturnsfromafile:
vmrun -T ws -gu guestUser -gp guestPassword runScriptInGuest Linux.vmx /usr/bin/perl -pi open(DOS, /tmp/dos.txt); while (<DOS>) { s/\r\n/\n/ ; print <DOS>}

RunaPerlscriptinaWindowsguesttoinsertDOSstylecarriagereturnsintoafile:
vmrun -T ws -gu guestUser -gp guestPasswd runScriptInGuest WinXP.vmx C:\cygwin\bin\perl.exe -pi open(UNIX, C:/Temp/unix.txt); while (<UNIX>) { s/\n/\r\n/ ; print <UNIX>}

VMware, Inc.

11

Using vmrun to Control Virtual Machines

Examples From the Usage Message


StartavirtualmachinewithVMwareWorkstationonaWindowshost:
vmrun -T ws start "c:\my VMs\myVM.vmx"

StopavirtualmachinewithServeronaLinuxhost:
vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPasswd stop "[storage1] vm/myVM.vmx"

RunaprograminavirtualmachineonaWindowshostwithaWindowsguest:
vmrun -T ws -gu guestUser -gp guestPassword runProgramInGuest "c:\my VMs\myVM.vmx" "c:\Program Files\myProgram.exe"

RunaprograminavirtualmachinewithVMwareServeronaLinuxhostwithaLinuxguest:
vmrun -T server -h https://myHost.com/sdk -u hostUser -p hostPasswd -gu guestUser -gp guestPasswd runProgramInGuest "[storage1] vm/myVM.vmx" /usr/bin/X11/xclock -display :0

CreateasnapshotofavirtualmachinewithVMwareWorkstationonaWindowshost:
vmrun -T ws snapshot "c:\my VMs\myVM.vmx" mySnapshot

ReverttoasnapshotwithVMwareWorkstationonaWindowshost:
vmrun -T ws revertToSnapshot "c:\my VMs\myVM.vmx" mySnapshot

DeleteasnapshotwithVMwareWorkstationonaWindowshost:
vmrun -T ws deleteSnapshot "c:\my VMs\myVM.vmx" mySnapshot C:\Program Files\VMware\VMware Workstation

Examples from Workstation Manual


ResetavirtualmachineonLinux:
vmrun reset /usr/local/VMs/<virtual_machine_name>.vmx soft

ResetavirtualmachineonWindows:
vmrun reset C:\Virtual Machines\<virtual_machine_name>.vmx soft

Disabling Dialog Boxes


WithvirtualmachinesthatrequireinputthroughaVMwareWorkstationdialogbox,thevmruncommand mighttimeoutandfail.TodisableWorkstationdialogboxes,insertthefollowinglineintotheconfiguration file(.vmx)foravirtualmachine:
msg.autoAnswer = TRUE

12

VMware, Inc.

You might also like