Shortcut pointing to Batch script (.bat file) - PSF Tool not worked.

Brass Contributor

Hi All,

Scenario: I have an app with multiple shortcuts, in those one shortcut's Target is "cmd.exe" and argument is path of a batch script file(.bat file). I have tried to create MSIX package with the help of PSF Tool. while testing I am able to launch every shortcut, except this one (which has batch script).

 

I tried the below things:

1. As we know there is no communication between MSIX container and the native cmd.exe file, I have copied cmd.exe (which is not recommendable) file into msix package and tried to launch the shortcut. It didn't work.

2. In config.json file, replaced cmd.exe with the psflauncher.exe in place of target, which mean this psflauncher will call the .bat file to execute. It didn't work

3. In config.json file, placed .bat file path in Target place with out any arguments. It didn't work.

 

Is there any thing else to try other than above, please advise and guide.

Thanks in Advance.

 

 

30 Replies

Can anyone help me on this situation.......frequently I am facing the scenario, where target has cmd.exe and argument has a .bat file or sometimes directly .bat file in target, there type of shortcuts were not working even with psf tool also.

I assume from this "PSF Tool" here is PsfTooling and you are capturing an installer using the Microsoft MSIX Packaging Tool. PsfTooling should detect your shortcut to the cmd file and do everything for you.

If my assumption is correct: Can you share the contents of the cmd file, as well as the config.json file? If you don't want to post them here, reach out to me as tmangan @ tmurgent.com

If you are building a package in other ways, you'll need to provide those details.
Hi, i am trying the same. Did you get it working already?
Hi @ Johan Pol, I didn't get any solution.
I got it working now. I guess it is a bug, but when you configures a startscript in the config.json it starts working.
Hi @ Pollewops
If possible, could you please paste or attach that config.json file for reference.. I would like to try it.
Thanks in Advance.

Try this config.json file to start the test.bat file. Create a dummy AppLauncher.ps1 and put that one in the root of the package.
{
"applications": [
{
"id": "PSFLAUNCHERSIXFOUR",
"executable": "VFS\\ProgramFilesX64\\Test\\cmd.exe",
"arguments": "\/c VFS\\ProgramFilesX64\\Test\\test.bat",
"workingDirectory": "",
"stopOnScriptError": true,
"startScript":
{
"scriptPath": "AppLauncher.ps1",
"scriptArguments": "",
"runInVirtualEnvironment": true,
"showWindow": false,
"waitForScriptToFinish": true,
"runOnce": false
},
"endScript":
{
"scriptPath": "AppLauncher.ps1",
"scriptArguments": "",
"runInVirtualEnvironment": true,
"showWindow": false,
"waitForScriptToFinish": true,
"runOnce": false
}
}
]
}

 

i put the cmd.exe in the package. This to be able to start the script in the bubble. If i used c:\windows\system32\cmd.exe it runs outside the bubble. Also to let the cmd.exe work correctly, a subfolder en-us with cmd.mui.exe is required.

 

@tmangan is this expected behavior?

@Siva116 If you could post your bad version, that would be helpful.  I've been working on some PSF FRF issues seen in your Java App and plan to hit up scripting issues in the Launcher before releasing.

Hi @tmangan, i also today tried to create msix application. Before the exe starts, a java.exe version needs to start as startup script. I can’t get it working. Is something similar appears with you?
Generically Java shouldn't be a problem, however the app I mentioned was using a 1.4 version of Java which has lots of problems. Once I clear out some other PSF issues I will be looking at scripting to see what is up. Generally, scripts are working, so posting specifics on problems is always helpful.
So what version of Java, is it inside the package or locally installed, what does the script look like.

@TIMOTHY MANGAN thanks for your responses.....we have Zulu Java 1.8 version installed in the package. The current config.json we use looks like:

{
               "applications": [{
                              "id": "PSFLAUNCHERSIXFOUR",
                              "executable": "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
                              "arguments": "-ExecutionPolicy Bypass -Command \"& {Invoke-CommandInDesktopPackage Test-0607.01-ENG_fg0t8wag126gc PSFLAUNCHERSIXFOUR cmd.exe '\/c c:\\progra~1\\Test\\Test\\bin\\runclient.bat' -PreventBreakaway}\"",
                              "workingDirectory": "",
                              "stopOnScriptError": true,
                              "startScript": {
                                            "scriptPath": "AppLauncher.ps1",
                                            "scriptArguments": "",
                                            "runInVirtualEnvironment": true,
                                            "showWindow": false,
                                            "waitForScriptToFinish": true,
                                            "runOnce": false
                              },
                              "endScript": {
                                            "scriptPath": "AppLauncher.ps1",
                                            "scriptArguments": "",
                                            "runInVirtualEnvironment": true,
                                            "showWindow": false,
                                            "waitForScriptToFinish": true,
                                            "runOnce": false
                              }
               }]
}

AppLauncher.ps1 is just a dummy file since without a startScript it seems to fail.

runclient.bat is a command file which starts the java.exe with arguments.

Above seems to work although it looks terrible due to the popup boxes of PowerShell and CMD.

But maybe you have some additional tips to make this easier configured. The final situation should be that the JAVA.EXE should be started in the bubble.

 

 

Thanks for posting the json. I'm not sure why the main bat file is started via cmd inside a powershell, but the scripting portion looks fine.

I am looking at this as a problem with the PSF scripting. I'll let you know when I have it sorted out, but a new version of PsfTooling to include the PSF update will be needed.
Any idea when new version is available? Or can i subscribe somewhere to get info about new version?
I have a fix for the scripting, but it is part of a major PSF set of changes I've been working on to resolve a bunch of PSF issues. There is still one more issue that needs addressing (cross architecture processes) and a bunch of testing. Hopefully released around end of month. I'll update this thread as well as posting to my blog over on tmurgent.

@TIMOTHY MANGAN related to your answer, you posted: Thanks for posting the json. I'm not sure why the main bat file is started via cmd inside a powershell, but the scripting portion looks fine.

 

Is there another way of starting the BAT file, which is located in the bubble and should be run in the bubble? This seems to be the only way we could find. Another way was to use CMD.exe, but then it works only when we used a cmd.exe copy added to the package. When we ran c:\windows\system32\cmd.exe it seems the BAT file does not start in the bubble, but outside :(

My 2021.09.26 build of the PSF will now let you have PsfLauncher executable be a cmd or bat file that will run inside the container.
Wauw you did made some important changes. Will test them hopefully tomorrow.
THANKS
Thanks a lot @TIMOTHY MANGAN for the updated version with fixes......

Tested by colleague of mine and new psflauncher seems to work and BAT/CMD files can be started directly by psflauncher32.exe in json file