Jump to content
Server Maintenance This Week. ×

Send Event to create BAT file


This topic is 3259 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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!

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

This topic is 3259 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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