I need to create WinRAR SFX archive that should work with admin permissions on Windows 7. I can make it with WinRAR GUI but I need to make it with WinRAR command line interface (to integrate it into build process).
At the moment my script is like that:
rar.exe a -sfxdefault.sfx archive.exe some_file_to_be_in_sfx
rar.exe c archive.exe -zscenario.txt
while scenario.txt is
TempMode="Extract data from archive?","Title"
Any suggestions are welcome!
First, take a look on question How can I automate the building of this Winrar Sfx File.
Second, if you have open the tab Advanced of Advanced SFX options dialog with the option Request administrative access in WinRAR GUI, there is a button Help which opens the help page for this dialog. This help page contains:
Request administrative access
Set this option if you wish to create SFX archive, which will request the administrative access when started in Windows Vista and later. This option does not change behavior of SFX archive in older Windows versions.
Corresponding command line switch is -iadm.
And this answers your question. -idam is on help page a hyperlink to the help page of this switch.
But the text file Rar.txt in program files folder of WinRAR containing an explanation of all commands and switches supported by console version Rar.exe does not list this switch nor does Rar.exe output it on running it from within a command prompt window with no parameters to get displayed the help for console version.
This means only WinRAR.exe supports the switch -iadm, but not console version Rar.exe. But this is no problem as WinRAR.exe can be executed also from within a batch file from console, best with using background process option -ibck.
Note: Best on creating the command line for WinRAR.exe is opening in help the page Alphabetic switches list via Contents - Command line mode - Switches and read from top to bottom while building the command line. Add the switches you need for creating the SFX archive.
For example:
WinRAR.exe a -cfg- -ep1 -iadm -ibck -inul -k -m5 -ma4 -md4m -r -s -sfxdefault.sfx -tl -y -zscenario.txt archive.exe some_file_to_be_in_sfx
May be Its too late to answer this Question but Simple solution to this is command
"C:\Program Files\WinRAR\WinRAR.exe" a helpTestUpdate -s -sfx logFile.txt
This will take the logFile.txt and convert it to the .exe sfx file.
Related
I have a few applications that I am trying to deploy with SCCM 2012 but the installations are failing through the application catalog. So what I have for the deployment type is a script installer. I have "cmd.exe" (Without quotations) in the Installation program field and "Installer.bat" in the installation start in field.
When I look at the ccmcache folder, all the contents over that application are there but the following error displays the Software Center:
0x8007010B(-217024629)
I have done some reading online and the "10B" is a common command line error for invalid directory. I have tested the batch file when hard coding a path but my question is, how can I edit the batch file or SCCM to pull from the CCMCache path where the files are downloaded to on the local client? Currently the Batch File is simply:
#echo off
ApplicationName.exe
Do I need to edit the file to cd into the CCMCache folder where the files are placed? How can I get the batch file to run the executable that is downloaded to the CCMCache folder?
Thank You!
You need to have the full path to the installation in your script
#echo Off
\\path to .exe
The way the command is written will not be able to find the .exe file. You need to add the full unc path to the .exe into your .cmd file. You should have your installation .exe and .cmd file in the same location on the distribution share
Recommended Solution:
Before starting, since you are only launching an exe with your batch file, I would recommend just using your ApplicationName.exe as your command line parameter in SCCM instead of using a batch. This will eliminate the need to engineer any further.
Modifying the existing solution to work:
If you do still want to use a batch file, keep a few things in mind. The syntax you are using to launch the batch file will not work. I would recommend just using the batch file name "installer.bat" as your command line. If you still want to preface the batch with the cmd.exe, you absolutely need to use the /c switch with it
cmd.exe /c installer.bat
If you don't use /c the console host will only open to a promopt and not execute your batch.
This is not an ideal solution though because using "cmd.exe /c" will set your working directory to the location of cmd.exe (ie "C:\windows\system32") and since your content is staged in ccmcache, you will need to specify its location within your batch. To do this, you would use %~dp0 variable which gives you the directory the current batch is running from. This means modifying your batch to read
#echo off
%~dp0ApplicationName.exe
I am working on a program to auto update my game as I make new developments and add new patches. When I go to run the patch update it doesn't recognize wget as a internal or external command.
Game:
:Checkforupdates
cls
cd C:\AirlineSim\
echo Checking for Updates
wget "http://interversesoftware.weebly.com/uploads/4/8/5/8/48585729/aspatcher.bat"
if /i not exist "ASpatcher.bat" (echo Could not retrieve update file.) && pause
if exist "ASpatcher.bat" call "ASpatcher.bat"
if exist "ASpatcher.bat" del "ASpatcher.bat"
goto menu
More code above in the updater
Updater:
cd C:\Airlinesim
echo Updating...
echo.
if /i exist Airline_Simulator.bat" del Airline_Simulator.bat
wget "http://interversesoftware.weebly.com/uploads/4/8/5/8/48585729/airline_simulator.bat")
set version=2.0
wget is a third-party program that doesn't come bundled with Windows, so you need to explicitly install it in order to use it.
You can find (one of) the Windows versions here: http://gnuwin32.sourceforge.net/packages/wget.htm
You will need to add the path of the wget.exe file to your PATH environment variable in order to call the executable as in the batch file above without explicitly specifying the path.
For Windows 10: A good link is available here: https://builtvisible.com/download-your-website-with-wget/
I followed this tutorial-> (https://builtvisible.com/download-your-website-with-wget/) and it worked for me. Still, I will give an overview of that,
credit: Richard Baxter
for 64bit version download wget from here
move your wget.exe to the Windows directory, which is generally c:\Windows\System32.if you don't know then you can find that either using the $PATH command or by opening your cmd as an administrator and in which path it will open that will be your Windows directory. like this one ->
2.1. Check that you have copied that in a proper place or not, to do that restart your cmd/terminal then type wget -h. if it gives some output related to some commands and their utilities(basically what a help command does) then you are good to gođź‘Ť.
If you pass the above check, then go to your c:/ directory using cd .., then make a directory called wgetdown using md wgetdown. Now you are all set. use get how ever you want.
What this simply means is, wget isn’t installed in your windows machine or it is, but hasn’t been added to Windows environmental path.
If you don’t have wget installed, download it from here (32-bit) and here (64-bit).
Extract the files to a folder say C:\wget and then add the folder to Windows environmental path.
Go to C:\Program Files (x86)\GnuWin32\bin folder and check the .exe file name.
For me it was sid.exe so I'm using sid instead of Wget command
download wget.exe here after downloading, go to command prompt by typing 'cmd' in the search menu, open the cmd type 'path' then enter in the command prompt, you're going to move the downloaded wget.exe to C:\Windows\System32 folder. if its successful, close and open the command prompt and type 'wget -h' then enter you should see different available commands. You can now use 'md wgetdown' to create directory for your downloads
first you have to install wget
pip install wget
than in Jupiter notebook locally on Windows 10
!python -m wget
example
!python -m wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1InzR1qylS3Air4IvpS9CoamqJ0r9bqQg' -O inception.py
You simply need to install wget from https://anaconda.org/menpo/wget here. I found my solution by installing it.
I had a similar issue, and I resolved it by using Windows PowerShell instead of Command Prompt
The answers about it not being available by default are absolutely correct. A few other notes related to installing wget - if you use a package manager, they may have it for you to install with.. e.g.:
$ choco install wget
$ composer require fawno/wget
done a search on this, but little joy. I am making and later, trying to delete a folder in the same batch file:
mkdir "%_gameKey%"
:: Stuff.....
rmdir /s /q "%_gameKey%"
I get the error "the process cannot access the file because it is being used by another process." I also can't delete the folder via right-click delete - same error. Interestingly, the rmdir removes the contents of the folder. There is nothing in the folder, nor is there anything obvious accessing it.
I have used Unlocker - shows no processes. Have also used Process Explorer, searched on the folder name (with/without full path) - no search results.
When I restart my machine, I can delete it. Not sure if down to user permissions. I see from this that Users only have Read/write not full control. (sorry - not very good with user permissions stuff - especially on windows!). However - surely it can't be this as I can delete it upon restart.
The folder is on a non OS drive.
I'm stumped - any ideas?
A folder cannot be deleted on Windows if any application uses this folder currently as working directory.
In your case I suppose that the batch file uses command cd to change the working directory to the created directory. So you need to use cd once again to set a different working directory before using command rmdir to delete this directory.
It is of course no good idea to start other applications with working directory being currently the directory which should be deleted later and which continue running on exit of batch file as those started applications have this directory as working directory as well.
I had same issue, after launched a powershell process from a folder via win cmd.
After powershell finished, I cd .. in win CMD but rd /q /s gave error: open in another process
I get same error when manually delete folder in explorer window, even if it was empty.
wmic process revealed that powershell.exe could be locking the folder, even though powershell had finished the task & powershell window had closed.
This was confirmed by tasklist
I then taskkill /im powershell.exe, after which the folder could be deleted.
My word - that was an obscure one, but finally found the answer by stepping through the code putting the rmdir in various places. I post this here in case anyone encounters the same...
Basically, I was calling cmd prompts and launching external exe's whilst in the said folder. Later, I was forcibly closing the exe's with TaskKill, but this was leaving the cmd consoles open at the path of the directory I was trying to delete. I'll try be clearer....
Whilst batch script was in the directory (e.g. C:\Windows\Scripts\Launch), I used the following command:
Start "AppLaunch" Call "!_supExe!" !_supCmd!
Which, after expansion, translated to, for e.g.:
Start "AppLaunch" Call "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
I was using this because, from reading, there appears to be a bug in windows making the following command fail:
Start "AppLaunch" "C:\Windows\Program Files(x86)\Troubleshooter\trbshtr.exe" -game "My Game"
The problem comes when you have to use quotes for both the exe and the parameters (for instance where there's spaces). Windows doesn't read it right. Thus had to use topmost to launch these apps.
Problem being, when used:
taskkill /f /im trbshtr.exe
The exe was killed, but the command prompt wasn't. Using /b on the Start command made no difference.
So, the solution was - cd out of the directory into one that the batch script doesn't alter before launching the other apps via the above. Job done....
Now that just leaves me with how to close all those opened cmd windows (or those in taskmgr if I use the /b switch). That's probably a topic for another search or thread!
I am trying to set up an automatic download of the files from a FTP directory on a scheduled basis. The solution I have come up with is to create a batch file that will be ran by windows task scheduler. The batch file is as follows (so far)
prompt
open ftp://xx.xx.xx.xx
myuser
mypassword
lcd C:\localdir
cd /remotedir/
mget *
quit
The problem is that this does not get everything in the specified directory. Only the loose files in the directory such as a .zip or .txt file. I have searched the questions here to no avail. So how can I get mget to not only download loose files in the root directory but also download the sub-directories and containing files (keeping the structure intact)?
Just answering this in case anyone else has a similar issue. The ftp.exe was a bust but I found out it is fairly easy using WinSCP just create a scheduled task in task scheduler and use the options section for command line parameters
Instructions for creating download script with WinSCP:
http://winscp.net/eng/docs/guide_automation
Instructions for scheduling WinSCP transfer task:
http://winscp.net/eng/docs/guide_schedule
WinSCP downloads directories recursively by default.
The goal behind this question is to create a portable Windows script/program that would help users run (console) programs directly from a USB key (not necessarily through autorun, though). The script/program would thus do the following when double clicked on:
Launch a console (cmd would do) and give a DOS command prompt,
Have the current directory set to a specific directory WorkingDir on the USB key (which contains various [Python] programs),
Set the path so that the user can run a command (python.exe) found in another USB key directory (so that the user can launch various Python programs found in WorkingDir).
The whole thing is based on Portable Python, which is on the USB key. I would also like to be able to simply put the contents of the key on a hard drive and use it from there.
I tried to write a file that contains commands like:
PATH=..\"Portable Python 2.7.2.1\App":%PATH%
cd WorkingDir
cmd
but I'm not sure how to call it so that Windows runs it (and I was therefore not able to see whether these command would work).
I don't know much about DOS and Windows, so any help would be much appreciated!
Actually, in windows you use ; for separating paths :) And you shouldn't use .. like that. You can use %CD% to get current directory and then navigate from it. And don't use quotes. Also, you could put # before any command that you don't wish to be echoed to the console.
You can put this into run.bat (this should work :P):
#PATH=%PATH%;%CD%\..\Portable Python 2.7.2.1\App
#cd WorkingDir
#cmd
And then just double click it and it will open commmand prompt just as you want it. Or maybe you can add autorun.inf file to open it automatically.
You need to create two files:
autorun.inf
[autorun]
open=cmd.exe "Python Console" /k autorun.cmd
action=Open Python Console...
autorun.cmd
#Echo Off
CD %~d0\WorkingDir
Path %Path%;%~d0\Portable Python 2.7.2.1\App
The phrase %~d0 represents the drive the command file resides, namely the flash drive's letter (E:).
Now, I encountered two slight hiccups. My USB drive had a hidden, system, readonly autorun.inf file on it already. I had to unprotect it with the following command before I could edit it.
Attrib autorun.inf -r -s -h
My second hiccup, is that Windows 7 won't autorun from a USB drive. You have to right-click the drive in Explorer and select "Run Python Console..."