I need to export/import my spk file via windows Batch script.
For which I have been referring this document
But this document does not mention how to save the file (I mean with which extension .bat or .sas)
My command:
ExportPackage -profile "SAS_MW_TEST" -package "F:\mypath\Package4.spk" -objects "/_Applications/_05_MW/_01_SAS_MW/_20_Processes/savedesk(Folder)" -subprop -types "Condition,BusinessRuleFlow,ExternalFile,Cube,SearchFolder,Table,GeneratedTransform,OLAPSchema,InformationMap.OLAP,Measure,Column,Job.CubeBuild,Action,Library,MiningResults,DeployedJob,CalculatedMeasure,Hierarchy,InformationMap.Relational,RootFolder,Prompt,Document,ConditionActionSet,DecisionLogic,Dimension,Note,StoredProcess,PromptGroup,Job,OrchestrationJob,MessageQueue,Service.SoapGenerated,Level,SharedDimension,DeployedFlow"
ExportPackage is an executable program that you can run out of a batch file.
Use Notepad or any other text editor (which includes any SAS code editor), place the ExportPackage program command in the editor and use the File/Save As feature to save the file as something like myPackageExporter.bat
If the items in the package are say stored processes whose metadata says the source code is in an file system folder (aka source code repository), you will probably also want to zip up the folder.
This macro can help you prepare the batch script, ready for export: https://core.sasjs.io/mm__spkexport_8sas.html
Related
Using Windows 10, Octave 4.4.1, and Excel 2016, I have an Octave script (call it "MyOctaveProgram.m") that takes data from a text file ("MyTextFile.txt"), which can be loaded with the uigetfile function, but for quicker access, I've created a batch file:
#echo off
C:\Octave\Octave-4.4.1\octave.vbs --force-gui --eval MyOctaveProgram("'%~d0%~p0'","'%~n0'")
cmd /c
The .bat file has the same name as the .txt file, other than the extension.
So far, this all works fine, and I can execute part of MyOctaveProgram.m via the GUI command line, or through the batch file. The difference comes in when I try to use a part of my code that creates a data table in Excel (with the COM interface), using
xls=xlsopen(ExcelFile)
xls=oct2xls(data...)
xls=oct2xls(more data...)
xls=oct2xls(etc...)
xlsclose(xls)
This works fine when I run MyOctaveProgram.m from the GUI command line (choosing MyTextFile.txt with the uigetfile function), but when I try to create the Excel file when running Octave through the batch script above, I get the following message:
(File pointer preserved. Try saving again later...)
This seems to produce no errors, and the session stays open (unlike the GUI, the batch-initiated Octave session will terminate if there's an error), but the Excel file is not created. There are no other Excel windows or tasks open, and I'm not trying to overwrite an existing file. Any advice would be appreciated!
I am working on a project that uses Huffman algorithm to compress files, and I am doing my project using Java, what I want is to create my own file extension say (.huff) for the compressed file, and when I right click a file if it has the (.huff) extension, I want to add a new option which decompresses it, I searched the web but I did not find anything useful.
Any help would be appreciated.
To set the file extension just use one of the String methods like append(".yourExtension") (append it to the filename) and set as filename. Simple as that.
String filename = filename.append(extension);
To decompress the compressed file, I suggest you write a metod to which you provide a path to file as argument, check if the file extension is correct and then in another method you decompress this file.
There is nothing special about a file extension, it's just a part of the file name. To create a .huff file extension, just add .huff to the end of the file name.
To add the windows context menu, that's explained in the question linked in the comments How can I add a context menu to the Windows Explorer for a Java application?
I would recommend creating a batch script that will launch your program taking in the file to decompress as an argument.
Something similar to:
#echo off
java -cp <path-to-jar> <decompression main class> %1
Adding in any other setup or program arguments you need. Then a registry entry might look like.
HKEY_CLASSES_ROOT\.huff\shell\Decompress huffman encoded file\command
"<path to batch file>" "%1"
I have an internal software that generates folders with batch files. The batch file is supposed to run a matlab file in the same folder, but in fact it just runs Matlab and the previous Matlab script (not the one in its folder).
I need a command in my batch file to recognize its own location(folder) and run the matlab file from the same folder.
Thank you in advance
use the %0 parameter. This on is an implicit parameter that you do not pass to the scrip
try this and see if it helps you get going:
#echo %~dp0
the ~dp sequence strips the name and extension from the full path to the script.
note that this works only from within a script, not from the command prompt
References: for-command
I can find plenty of answers on the internet about how to open a specific file, e.g. http://answers.yahoo.com/question/index?qid=20080102230630AAfu5dF
However, I need to provide a way of opening a non-specific file in a program called by a batch file.
To explain, here is an example. The user has a folder with 100 files in with the .xyz extension. He wants to be able to double click on ANY file and open it in his "XYZ Viewer," but to run his XYZ Viewer he needs to run a batch file that alters his registry and then runs the actual XYZ Viewer .exe.
If you select the batch file to be the default program via the "Always use the selected program to open this kind of file" tickbox, it will open the program, but without using the standard Windows function of opening the file that instigating the running of the program.
Is there a way to run the program through the batch file and for it to both run the program and open whichever file it was that instigated the running of the program?
I suspect this is impossible, but any suggestions would be very gratefully received!
Cheers.
Edit:
The program does eventually support opening a file placed as an argument to it.
My code is
reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe
Does the program eventually support opening a file placed as an argument to it? In the example you linked, mspaint opens the first parameter given to it.
If your batch file isn't currently doing this, you will have to edit it to contain the batch parameter(s).
See http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true for some fuller documentation on it.
Essentially you want to add %1 somewhere like:
reg import c:\regent\31.2.03.reg
start C:\Program\Program.exe %1
I want to know simply how to create a batch file from .exe file?
If you mean you want to create a new batch file from an unrelated existing executable file (in other words, the batch file does something different), you do it the way you create any file. In C, you'd use fopen, fwrite and fclose to create your new file and write whatever batch file commands you want to it.
If you mean you want to create a batch file that "intercepts" your exe file, you can do that too. If your executable file is pax.exe, you can simply rename it to pax2.exe and create a batch file called pax.cmd thus:
#echo off
pax2.exe
This will allow you to do arbitrary actions before and after your executable runs but there are things to watch out for such as executables that return control before they're actually finsihed.
If, however, you're talking about converting an arbitrary executable into a batch file that performs the same task, that's much more difficult. Unless you have the source code or a very good specification on how the executable works, you're going to have a lot of trouble.
Automating the conversion for anything but the simplest executable will be insanely difficult.
And, if you want a link to a batch file that runs your executable, just create the batch file (say in c:\bin\pax.cmd) containing:
#echo off
c:\bin\pax.exe
and then create a shortcut to it from wherever you want (such as the desktop). You could even put the batch file itself in your desktop directory but I'm not a big fan of that. However, to each their own.