Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Send Event to create BAT file

Featured Replies

I am trying to use Send Event to create a BAT file on my Desktop.

I have used the Send Event before and believe this should be possible using this script step.

I have this:
Set Variable [$file ; get (desktoppath ) & "test.bat"]
Send Event ["aevt" ; "odoc" ; "cmd /c echo test> " & $file

Which I would expect to create the file test.bat on my Desktop with the word 'test', as when I run this from cmd in any directory it creates the file as expected. However this isn't working using Send Event.

I used Substitute to change the \ in the filepath to / but it also didn't work.

Any help would be great thanks!

Your Send Event does not target the test.bat, you have to specify the full path to your test.bat file (and for good measure also specify the ".bat" extension).

If your batch file is not too complex you don't need to create a batch file in the first place.  You can do something like this:

cmd /c command1 && command2 && command3 ...

  • Author

you have to specify the full path to your test.bat file..

Thanks for your reply!

I have created the variable $file with the full path name, so I don't quite understand.

Effectively I am doing this:

Send Event ["aevt" ; "odoc" ; "cmd /c echo test> " & get ( desktoppath ) & "test.bat"

Your $file variable holds the path in FM format, not the format that Windows understands.

The variable will be something like:

file:/c:/<somewhere>

but windows expects

c:\<somewhere>

So you have to do the proper substitutions...

  • Author

Your $file variable holds the path in FM format, not the format that Windows understands.

The variable will be something like:

file:/c:/<somewhere>

but windows expects

c:\<somewhere>

So you have to do the proper substitutions...

​I also stated that I tried using Substitute / for \ and it still didn't work

Why don't you test the expression in the Data Viewer and compare its result with the shell command that works?

  • Author

Right, so it turns out it is a leading / that was causing the issue.

  • Author

So now the next issue I am having is I have the template for the BAT file stored in a field, which I then replace the keywords with the parameters and want to construct that file.

The problem is - The 'Batch' field has multiple lines, but when it creates the file it does not put the new lines in and in turn causes the file to not work.

Do you know anything about this?

By multiple lines, I mean separated by carriage return.

Edited by MattyM

  • Author

 Think I've solved it all.

Thanks for the contributions :)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.