Matt Malyschko Posted May 24, 2015 Posted May 24, 2015 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> " & $fileWhich 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!
Wim Decorte Posted May 24, 2015 Posted May 24, 2015 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 ...
Matt Malyschko Posted May 24, 2015 Author Posted May 24, 2015 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"
Wim Decorte Posted May 24, 2015 Posted May 24, 2015 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...
Matt Malyschko Posted May 24, 2015 Author Posted May 24, 2015 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
eos Posted May 24, 2015 Posted May 24, 2015 Why don't you test the expression in the Data Viewer and compare its result with the shell command that works?
Matt Malyschko Posted May 24, 2015 Author Posted May 24, 2015 Right, so it turns out it is a leading / that was causing the issue.
Matt Malyschko Posted May 24, 2015 Author Posted May 24, 2015 (edited) 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 May 24, 2015 by MattyM
Matt Malyschko Posted May 24, 2015 Author Posted May 24, 2015 Think I've solved it all.Thanks for the contributions
Recommended Posts
This topic is 3511 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 accountSign in
Already have an account? Sign in here.
Sign In Now