VMware {code} Community
hsmvm
Contributor
Contributor
Jump to solution

vmrun and shared folders

I have been trying nearly every combination i can come up with, and searching the web (and mostly these forums) for an answer, so I apologize if this is answered somewhere.

I am trying to use virtual machines to run my compilations for automated nightly builds and such. naturally I would have to use vmrun. What I can't seem to get working is using a shared folder to access the source folders. I know this is the problem and not the mechanic I am using to start the compilations because I can copy the source to the VM and use the same process and it works.

Here is the intended process:

vmrun start <vmx> nogui

sleep.bat 240        (batch file for ping -n %1, etc, to wait until the VM comes up well enough)

echo net use Y: "\\vmware-host\Shared Folders\job_share" /p:no > C:\run\run_net.bat

vmrun -T ws -gu <user> -gp <pass> copyFileFromHostToGuest <vmx> C:\run\run_net.bat C:\run\run_net.bat

vmrun -T ws -gu <user> -gp <pass> runProgramInGuest <vmx> C:\run\run_net.bat

echo ant -f Y:\build.xml > C:\run\run_ant.bat

vmrun -T ws -gu <user> -gp <pass> copyFileFromHostToGuest <vmx> C:\run\run_ant.bat C:\run\run_ant.bat

vmrun -T ws -gu <user> -gp <pass> runProgramInGuest <vmx> C:\run\run_ant.bat

vmrun stop <vmx> soft

I have tried using enableSharedFolders and addSharedFolder. Somewhere I read that you needed to map the folder with "net use". I've tried running with -interactive and -activeWindow, reading again somewhere that -interactive uses different processes to enable the shared folders that are already enabled as part of the VMX, but whenever I use -interactive to run the ant batch file, it get the error that the user needs to be logged in interactively.

Technically I could copy the source files to the VM before compiling and that would work. but There are many, many source files so that's impractical. I'm sure there is something that i'm missing, but i'm at a loss as to what. Please help.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
bottkars
Enthusiast
Enthusiast
Jump to solution

there is no Need to map the shared Folder. the UNC Path is availbale after you enable the Shared Folder for the Guest.

-interactive and -activewindow requires a user to be logged in. Are you using Autologon to have a login in the vm ? oterwise, leave those parameters

visit my Vmware Workstation/Fusion Powershell Toolkit https://github.com/bottkars/vmxtoolkit https://www.powershellgallery.com/packages/vmxtoolkit

View solution in original post

0 Kudos
3 Replies
hsmvm
Contributor
Contributor
Jump to solution

Really? no one using vmrun along with shared folders? I find that hard to believe.

0 Kudos
bottkars
Enthusiast
Enthusiast
Jump to solution

there is no Need to map the shared Folder. the UNC Path is availbale after you enable the Shared Folder for the Guest.

-interactive and -activewindow requires a user to be logged in. Are you using Autologon to have a login in the vm ? oterwise, leave those parameters

visit my Vmware Workstation/Fusion Powershell Toolkit https://github.com/bottkars/vmxtoolkit https://www.powershellgallery.com/packages/vmxtoolkit
0 Kudos
hsmvm
Contributor
Contributor
Jump to solution

thanks for the reply bottkars,

Well, don't i feel stupid. Obviously I know where my repos are via UNC, since I was attempting to map the UNC location to a drive, but i didn't actually try to point the command directly from the UNC path.

To test, I made a test.bat which was this:

echo "Hellow World!" > out.txt

while this works on the host, it did not work when i called this:

vmrun -T ws -gu <user> -gp <pass> runProgramInGuest <vmx> "\\vmware-host\Shared Folders\repos\test.bat"


The reason it didn't work was that the command prompt in the VM would change the default directory it would run in, since it says that UNC paths are not supported. So it changed it to C:\Windows, which gave me an access denied. This updated batch file did work however:


echo "Hello World!" > "\\vmware-host\Shared Folders\repos\out.txt"


With that, I can clean up the command a bit and point things directly to the UNC paths, but that's much nicer than trying to copy gigs of source code into the VM for compilation!


To answer your question, yes the VM requires a login, which is why i'm providing the user/pass through -gu -gp. Not using auto login. I did not end up needing -interactive or -activewindow.

0 Kudos