Create .bat or .cmd



Rep: (3)



Rep: (2705)
The paths to start should be written normally, and not my examples: D

Including instead of a shortcut to the game, look in its properties the path to the executable file and write instead of a link to the shortcut.
@echo off
WMIC PROCESS WHERE Name = "utorrent.exe" CALL Terminate
WMIC PROCESS WHERE Name = "Cloud.exe" CALL Terminate
WMIC PROCESS WHERE Name = "punto.exe" CALL Terminate
start / w% userprofile% \ Games \ Warface \ warface.exe
start% AppData% \ Roaming \ uTorrent \ uTorrent.exe
start "C: \ Program Files \ Yandex \ Punto Switcher \ punto.exe"
start% AppData% \ Local \ Mail.Ru \ Cloud \ Cloud.exe


Post has been editedShoore - 10.02.15, 19:24



Rep: (3)
Damn, why doesn't it work?



Rep: (2705)
why does not it work?
Open the command line and there try your commands one at a time.
If UAC is enabled, then for a batch file elevation of rights is necessary.
Not sure about Punto, but the 100% torrent starts from the profile, it doesn’t need the Program Files path. Write either
start C: \ Users \ ROMAN \ AppData \ Roaming \ uTorrent \ utorrent.exe
either try masks
start% AppData% \ Roaming \ uTorrent \ utorrent.exe

start% userprofile% \ AppData \ Roaming \ uTorrent \ utorrent.exe


Post has been editedShoore - 11.02.15, 20:17



Rep: (3)
Did so

The game closes, the programs start, and the second batch file is the other way around)))
So tnank you!



Rep: (1)
hi guru

who-thread can tell how a batch file can (and is it even possible) to enable / disable the standard firewall rule?
the challenge is that
there is:
1.a firewall rule named XXXXX
2. xxx.exe for which this rule is needed i.e. you cannot run xxx.exe without XXXXX enabled

need to:
1. enable rule XXXXX
2. run the xxx.exe file
3. When the xxx.exe file completes, turn off the XXXXX rule.
in clause 3 you can score if it is extremely difficult since I can’t imagine how the batch file can understand that the xxx.exe file worked and closed ..

thanks everyone :)

p.s. a batch file is not necessary, maybe there are other ways, but I don’t know about them, I will be glad to prompt
p.p.s. if I’m not asking here, then tell me the direction :)



Rep: (2705)
CrueL646 @ 05/16/2016, 10:48 PM*
how can a batch file (and is it even possible) to enable / disable the standard firewall rule?
:: Block
netsh advfirewall firewall add rule name = "deny_Program" program = "% name.exe%" dir = out action = block enable = yes

start% program.exe%
wait

:: Unlock
netsh advfirewall firewall delete rule name = "deny_Program"
This is a one-time offhand template. The correct syntax is necessarygoogle. In order not to create and delete a rule, but turn it on and off.

Although, if you understand why to disable such a rule, block the program once and that's it.

Post has been editedShoore - 16.05.16, 23:52



Rep: (1)
yes, I also found this article, but there is only to "create new" and play with them (add, delete, set, show), but I need an existing on / off, because if I will create a rule with a batch file, then I will hang myself :) there they write nothing about it :(

by the method of scientific poking it turned out, with the rules anyway, like this:

netsh advfirewall firewall set rule "XXXXX" new enable = Yes // on

start% windir% \ system32 \ notepad.exe // stuck a notebook for the test
wait //<- win10 does not know this command :(

netsh advfirewall firewall set rule "XXXXX" new enable = No // off

Shoore Thank you for the direction :)

Post has been editedCrueL646 - 17.05.16, 00:55



Rep: (2705)
CrueL646 @ 05/17/2016, 00:46*
win10 does not know this command
So try
Shoore @ 02/09/2015, 23:51*
start / wait "C: \ Users \ ROMAN \ Desktop \ Warface.ink"
There was something here tooSearch for programs and drivers for PC (Post Shoore # 30436118)
It turns out this way it will work
netsh advfirewall firewall set rule "XXXXX" new enable = Yes // on
% windir% \ system32 \ notepad.exe // wait for the program to finish
netsh advfirewall firewall set rule "XXXXX" new enable = No // off


Post has been editedShoore - 17.05.16, 01:17



Rep: (1)
Yes! already found like this - start / b / wait% windir% \ system32 \ notepad.exe
thank you :)

Well, in your last version there will be no waiting for the notebook to finish working, i.e. apply the rule - start the notebook - cancel the rule - complete * .bat - the notebook still works. not quite what i wanted :)
here is my working version (for win10 exactly fits):
netsh advfirewall firewall set rule "XXXX" new enable = Yes
start / b / wait% windir% \ system32 \ notepad.exe
netsh advfirewall firewall set rule "XXXX" new enable = No


strange, I try to start WorldOfTanks.exe through a batch file or console - it collapses without even loading up to the login window, I do the same thing, but through World of Tanks.lnk - it's all class ..
not to understand what .. protection is some kind of mega-curve or something ..?

p.s. maybe not the topic, but coolutility, from excerpt does exe :)

Post has been editedCrueL646 - 17.05.16, 02:07



Rep: (0)
Is it possible to create any document using the bat file that will be located in windows 10 autoload? On which PC you would not run it.



Rep: (11)
Guys, help me with a programming task to write a program for downloading files using the FTP protocol, while the server name, username / password, and the attacks themselves must be configured to download files ...
In general, there is a task, but there is no programming knowledge, I decided to get by a batch file, because I understand them more or less, I looked for similar scripts and came across this:
@echo off
:: Set connection parameters
set host = ftp.microsoft.com
set port = 21
set user = Anonymous
set password =
set Mainfolder =
set SubFolder = ResKit / win2000
set fileMask = *
set LocalFolder = c: \ temp

:: Temporary command file for FTP.exe utility
set CommFTP = "% temp% \ FTP_Script.txt"

:: Generate a file of FTP commands
>% CommFTP% (
echo open% host%% port%
echo% user%
echo.% password%
echo binary
echo prompt
echo hash
echo lcd "% LocalFolder%"
if "% Mainfolder%" neq "" echo cd "% Mainfolder%"
if "% SubFolder%" neq "" echo cd "% SubFolder%"
echo mget% fileMask%
echo disconnect
echo quit
:: Add FTP Utility to Windows Firewall Exceptions
netsh firewall add allowedprogram "% windir% \ system32 \ ftp.exe" ENABLE

:: Run the FTP command pack
ftp.exe -s:% CommFTP%

:: Delete the bag
del / f / q% CommFTP%
pause

And everything would be fine, but the server and login with a password are configured in the batch file, but I would like to select them somehow in windows forms, with the ability to change



Rep: (11)
* SKEALEKS, But what exactly is the purpose of creating such a batch file?
This will add the batch file to startup, and in the batch file it is fashionable to register the start of the desired program
copy ""% 0 "" "% SystemRoot% \ system32 \ File.bat"
reg add "HKLM \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run" / v "Filel" / t REG_SZ / d "% SystemRoot% \ system32 \ File.bat" / f
reg add HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ Explorer / v NoControlPanel / t REG_DWORD / d 1 / f
Just check the syntax for errors ...

Post has been editedsevervolk - 11.05.17, 19:43



Rep: (2)
Good time of day. I hope the topic is still alive.
There is such a problem, I am distributing Wi-Fi from a laptop, the Internet comes to it from a 4G modem.
I use these commands:
Cmd team
netsh wlan set hostednetwork mode = allow ssid = Wi-Fi key = 12345678 :: Create a virtual Wi-Fi access point
netsh wlan start hostednetwork :: START virtual wifi hotspot
netsh wlan stop hostednetwork :: STOP virtual Wi-Fi hotspots
netsh wlan set hostednetwork mode = disallow :: OFF Microsoft Virtual WiFi Mini Port Adapter
netsh wlan set hostednetwork mode = allow :: ON Microsoft Virtual WiFi Mini Port Adapter
netsh wlan show hostednetwork setting = security :: View password and other information (Only when a Wi-Fi network is running)
netsh wlan show hostednetwork :: Virtual Wi-Fi hotspot status information
netsh wlan show profiles :: View Wi-Fi to which you connected

But I was tired of constantly entering commands on the command line or using a separate .bat for each command and I decided to write .bat with the ability to select commands and the main undertaking I completed, a little later I wrote for myself the idea to make it for general use with help and opportunity solutions to most problems, and not just as now the main functions.
I wanted to make .bat understandable even to a full noob who knows how to click on the keys
And here is the .BAT itself
@echo off
@chcp 1251>nul
@TITLE WiFi Hotspot
: m1
Echo Select a program:
COLOR 1F
Echo
Echo 1 - Creating a Virtual Wi-Fi Access Point
Echo 2 - START Virtual Wi-Fi Hotspot
Echo 3 - STOP Virtual Wi-Fi Hotspot
Echo 4 - OFF Microsoft Virtual WiFi Mini Port Adapter
Echo 5 - ON Microsoft Virtual WiFi Mini Port Adapter
Echo 6 - View password and other information (Only when the Wi-Fi network is running)
Echo 7 - Virtual Wi-Fi hotspot status information
Echo 8 - View Wi-Fi to which you are connected
Echo? - Reference
Echo 0 - Exit
echo.
Set / p choice = "Your choice:"
if not defined choice goto m1
if "% choice%" == "1" (netsh wlan set hostednetwork mode = allow ssid = Wi-Fi key = h3jjWs7z-l9)
if "% choice%" == "2" (netsh wlan start hostednetwork)
if "% choice%" == "3" (netsh wlan stop hostednetwork)
if "% choice%" == "4" (netsh wlan set hostednetwork mode = disallow)
if "% choice%" == "5" (netsh wlan set hostednetwork mode = allow)
if "% choice%" == "6" (netsh wlan show hostednetwork setting = security)
if "% choice%" == "7" (netsh wlan show hostednetwork)
if "% choice%" == "8" (netsh wlan show profiles)
if "% choice%" == "?" (Echo Configuration and troubleshooting information.)
if "% choice%" == "0" (exit)
@pause
Echo
goto m1
pause>nul



By advice* LESHIY_ODESSA, I wanted to add commands under the spoiler:
To successfully raise a hotspot, it is necessary that:

1. Was launched - "WLAN Auto-Tuning Service"

sc config wlansvc start = auto :: startup type - "Automatic"
net start Wlansvc

2. The service was launched - "Internet Connection Sharing (ICS)"
:: sc config SharedAccess start = auto :: startup type - "Automatic"
net start SharedAccess

3. The service was launched - "Windows Firewall"
:: sc config MpsSvc start = auto :: startup type - "Automatic"
net start MpsSvc

It is also sometimes useful to enable the service, but to disable the firewall itself.

:: Disabling the firewall (we only need the service)
netsh advfirewall set allprofiles state off


But I ran into this problem: "To call additional help, type NET HELPMSG 2182"
This message does not bother me, but if you release this .bat to the network, many will be scared of this message.
I get this after almost every team on the advice* LESHIY_ODESSA,
After executing "NET HELPMSG 2182" I get the answer that "The requested service is already running"
Attached Image

I would also like to be able to use the command "netsh wlan set hostednetwork mode = allow ssid = Wi-Fi key = 12345678 :: Create a virtual Wi-Fi access point" change "sside = and key =" directly in .bat without editing it through notepad
In stages, as I would like to see:
1. in CMD we type 1.
2. CMD offers us to set sside =
3. CMD offers us to set key =
4. CMD executes the command with given sside = and key =

It would be ideal if there was an opportunity to set .bat and this is with the choice of the Network adapter from which the virtual adapter will receive Internet
although I’ve already been upset that it’s impossible "But I still doubt that many system administrators use .bat to configure not all the basic routine work with these .bat"
Attached Image


I will be glad of any help or tip where I dig to implement the planned

Post has been editedalieksandr.ierokhin.95 - 03.12.17, 11:44
Reason for editing: Supplement



Rep: (68)
Hello.
Interested in a program - a batch file.
I have a flash drive, on a flash drive, let's say a program.
The program has additional files.
In short, the program folder.

It is necessary that when starting this batch file on a USB flash drive, the program folder from the USB flash drive was copied to the computer and the program was launched. Bullshit, but so clear.

Thank you in advance.



Rep: (1062)
* elecktro1337,
@Echo Off
Set "DirOut = c: \ Program \"
Set "FileIn = \ Program \ *. *"
Set "RunEXE = program.exe"
xCopy / EY "% FileIn%" "% DirOut%"
start "" "% DirOut %% RunEXE%"



Rep: (68)
@Echo Off & title CFG Checker by Elecktro1337
color a
echo # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = #
echo # CFG Checker v34 by Elecktro1337 #
echo # --------------------------------- #
echo # Site - Elecktro1337.tk #
echo # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = #
echo.
echo Searching CFG ...
echo.
Set NameFile = cfg.exe
Set From = "% ~ dp0% NameFile%"

for %% d in (c d e f g h i j k l m n o p q r s t u v w x y z) do If Exist %% d: \ *. * (
FOR / F "usebackq delims =" %% f IN (`dir / s / b / a-d" %% d: \% NameFile% "2 ^>nul`) DO (
cls
echo # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = #
echo # CFG Checker v34 by Elecktro1337 #
echo # --------------------------------- #
echo # Site - Elecktro1337.tk #
echo # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = # = #
echo.
color 4
Echo %% f
echo.

)
)
pause


I have such a code.
Actually, this program sniffs all the disks on the cfg.exe file
But, displays only one file found.
How to make sure that all found files are displayed?
And how can I display my text instead of displaying the location of the found file?
And if the file is not found - a different text.



Rep: (0)
Guys, I hope I'm in the topic. Maybe someone knows how to do it: I often need to quickly change the screen resolution, say from 800 * 600 to 1024 * 768 or vice versa, can I create some kind of shortcuts or scripts?



Rep: (92)
There is a folder C: \ Myfolder \, in which there is a whole bunch of folders and files.
I need to make such a bat-file so that I can run it from any folder and at the command line, through the echo command, the size of the folder C: \ Myfolder \ is displayed to me.



Rep: (0)
Good evening. Interested in this question: is it possible somehow using cmd to copy a file to another location? I will describe more precisely.
There is a game, it has a launcher for launching. I can not start the game by executable file. The game has a settings file, which for some reason is reset every time. In order not to configure it again each time, I copied the settings file when everything is in order. And every time after starting the game, I replace the newly reset file with my own, with normal settings.
I want the console to determine if the game is running, and if it is running, it replaces the settings file for me. How to start the launcher and script with one click, I’ll figure it out myself, the commands there are obvious even for a teapot like me.


Full version    

Help     rules

Now: 09/02/19, 00:52