Hey there, I'm new here! I'm also still learning a lot about VMware in general! With that said, here is my problem:
I have a bat file whose purpose is to install software. In it, I have written the following three lines of code in a file named example.bat:
"Firefox Setup 42.0.exe" /S
"Firefox Setup 42.0.exe" -ms
Now, this bat file works if I actually log on to this remote computer and run it there. It performs the tasks just like I like and everything is groovy. However, if I run this bat file remotely from PowerCLI, it does not work. Rather, PowerCLI just shows the script running, but it hangs there and never seems to execute or finish. I don't see any processes or whatever being run on the remote machine either.
I run the following commands in PowerCLI:
$vm = Get-VM -Name "my_vm"
Invoke-VMScript -VM $vm -ScriptText "C:\TEMPINSTALL\example.bat" -HostUser username -HostPassword password -GuestUser username -GuestPassword password -ScriptType Bat
Here is some of the troubleshooting I have tried so far:
* I have changed ScriptType to Powershell and ran the command.
* I put a powershell file in there that would open the bat file, and had my Invoke-VMScript point to powerhshellscript.ps1 to open the bat file.
* I put a bat file to open the powershell file to open the bat file (because why not!) in the directory.
* I have spent many hours googling, and while I have found many scripts to run powershell from a bat file, I haven't found anything specific to this issue
* I have searched the section of this forum for related topics; again, nothing that solved the issue
* I made sure to run PowerCLI as an administrator
* I experimented with different bat files. I can actually run bat files through powercli that do simple things like make directories and files, just not actually install/uninstall software.
I'm at the end of my rope here, so I was hoping someone could point me into the right direction or even give me an idea of what I could research to approach this issue. Thank you very much for your time!
Not sure if you checked this, but the BAT file will run under the account you specify on GuestUser.
Is that account permitted to install SW ?
Did you already do a pslist (sysinternals) of the active processes on the target.
Just to check if the installation EXE is already started
Yes, the account is permitted to install SW. When I logged onto the computer, I ran the bat file as a different user and specified the GuestUser and the bat file ran correctly. As I am working in a secure environment, I am extremely limited to the tools I can download and use; as such, I cannot download and use pslist to see the active processes on the computer. Any other suggestions?
Right now, my new approach is to try to have powershell start a process and attach the bat file to that process. Then, I'll try to run the powershell script from powerCLI remotely. So far, it hasn't been working out!
Ok, that seems to indicate that the issue is very likely with the EXE you are trying to run.
When you run it interactively, with a runas, there is no popup or prompt ?
Is the 1st one, which is an uninstall, giving a prompt when the SW is not installed ?
I don't think it's with the EXE file, as it works perfectly if I just right click on the bat file and click on "Run As" and select administrator.
Could you expand a bit more on where exactly you are asking if there is a prompt or popup? That is to say, do you mean if I just directly open the .exe file itself with a RunAs? Or if I try to open it from command line without SW? In either case, it runs normally giving me prompts through a GUI.
Oh, do you mean to say I should try running it WITHOUT the SI/SU remotely to see if I can get a prompt? I know that it does uninstall/install silently when I have the /S and -ms commands after it correctly. I'll have to check to see if I can have it give me a prompt through GUI remotely.
Okay, I think I see where you are going with this. So, when I try to execute the .exe file remotely without silent options, it does not open and give me a GUI prompt. However, the script DOES hang all the same. As you said, it very well could be the .exe file. I'm going to try with a different installation file now and see if that changes anything.