How to add a file to a self-extracting RAR archive? - winrar

Is there a way to automatically add a file to an existing SFX archive?
I have created with WinRAR the self-extracting archive Test.exe.
Now I want to add C:\test\Test.txt to Test.exe. Is this possible?

Ok, i found out the following command line arg to do the trick.
"C:\Program Files\WinRAR\rar.exe" a -ep C:\test\test.exe c:\test\test.txt
-ep is a switch to ignore the path, which i wanted
a is to add.
more help is there if you run rar or winrar from command prompt.

Related

How to open all files in a directory from command prompt

I wan't to open up every excel file in a certain folder using the windows command prompt. I know I can do this if I know the name of each file, but I want to just open all as the file names might change. Thanks.
for %1 in (*.xlsx) do start excel "%%1"
In the command prompt, you can execute the above command which opens all the excel sheets in the current directory. You could store this as batch file by giving full path too
for %1 in (<path>\*.xlsx) do start excel "%%1"
Edit: As #CristiFati noted, if the excel is not there in the path,
for %1 in (<path>\*.xlsx) do "C:\Program Files (x86)\Microsoft Office\Office16\EXCEL.exe" "%%1"
Navigate to the folder in command prompt.
Then run the following command
FOR %F IN (*.*) DO START %F
Credit goes to here:
https://superuser.com/questions/1503993/cmd-command-to-open-all-files-in-a-subdirectory

Building my NSIS installer using Jenkins

I am very new to Jenkins and want it to build a complete .exe. I set the Repository to a personal URL, now Jenkins do read all the files and copies everything to the Jenkins Workspace. My question is what do I insert into the "Execute Windows Batch Command" block in Jenkins so that it would Compile a NSIS script and store the Setup file in a output file. I have done research into Windows Batch Scripting but nothing that could truly help me in this struggle. If I am doing it all wrong I would love some advice to get me on the right track. Here are my current Jenkins codes to read and safe the files from the repository:
1st "Execute Batch Command"
COPY "C:\Program Files (x86)\Jenkins\jobs\Job_name\Path\*.*" "C:\Program Files (x86)\Jenkins\jobs\Job_Name\workspace\Output\Installs" /Y
2nd "Execute Batch Command"
del c:\inetpub\wwwroot\downloads\%SVN_REVISION%\*.* /s /f /q
rmdir "C:\inetpub\wwwroot\downloads\%SVN_REVISION%"
exit 0
3rd "Execute Batch Command"
MKDIR "C:\inetpub\wwwroot\downloads\%SVN_REVISION%"
4th "Execute Batch Command"
COPY "C:\Program Files (x86)\Jenkins\jobs\Job_Name\workspace\Output\Installs"
"c:\inetpub\wwwroot\downloads\%SVN_REVISION%" /Y
Now all I want Jenkins to do is open my .nsi script, compile and create the Setup File which then saves in an output folder.
Create new batch command with following:
path_to_NSIS_folder>\makensis.exe path_to_your_nsi_file
makensis.exe is a NSIS compiler and all it needs is path to the script file (.nsi).
When run the script is compiled and (if no errors) reslting setup.exe is created (the output can se set in .nsi file).

Batch file replacing issue

I'm trying to change my group policies by replacing the scripts.ini file in C:\Windows\System32\GroupPolicy\Machine\Scripts by using a batch file. The batch file is on my desktop in a folder called replacer, the custom scripts.ini is in the same folder. When i right click the batch file and "Run as administrator" it suddenly can't find the scripts.ini file that's in the same folder. When i don't run as administrator it finds it, but can't replace the scripts.ini file in group policies.
Edit:
Here's the code(1 line):
xcopy /s/y scripts.ini C:\Windows\System32\GroupPolicy\Machine\Scripts
When you run a batch script by double clicking it, the current directory will be the folder where the script resides.
But when you run the script as Administrator by right mouse clicking, then the current directory is something else, typically C:\wINDOWS\system32.
Your script can use %~dp0 to get the full path of where the script is installed, so you can simply prefix your source file with that path:
xcopy /s/y "%~dp0scripts.ini" C:\Windows\System32\GroupPolicy\Machine\Scripts
If you have additional commands that depend on the current directory, then I suggest you use PUSHD to change your current directory instead
pushd "%~dp0"
xcopy /s/y scripts.ini C:\Windows\System32\GroupPolicy\Machine\Scripts

symbolic link to a text file in command line

Im trying to create a symbolic link to a text file with directory:
C:\users\me\textfile.txt
where the shortcut is in the same folder (for simplicity)
using command:
mklink /d "C:\users\me\textfileshortcut.lnk" "C:\users\me\textfile.txt"
but this just creates a folder with the name textfileshortcut.lnk and not a shortcut to a file.
What am i doing wrong?
I dont have too much experience with command line but i need it for this one task.
Create the symlink for a file using the below cmd command.
mklink "C:\users\me\textfileshortcut.lnk" "C:\users\me\textfile.txt"
/d or /D will create the directory symlink.

Add files to classpath or loops in batch files?

I have this script in BASH (linux) shells script that adds all *.jar files into the classpath automatically. Is there a way to do the in window's batch file or do I have to add all the files manually?
CLASSPATH=.
for file in ./libs/*.jar; do
CLASSPATH=$CLASSPATH:$file
done
Thanks!
See BAT file to create Java CLASSPATH
Use the forfiles command to loop over the file names.
forfiles /M .\libs\*.jar /C "cmd /c set CLASSPATH=%CLASSPATH%;#file"

Resources