Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How do I write a batch to run a .exe program

03 Sep 2012   #1
schnabel14

Windows 7 Home Premium 32bit
 
 
How do I write a batch to run a .exe program

I'm just getting into messing around with computer programming and such. Most of us are all familiar with the batch file that creates a private folder that you can lock and require a password. I am trying to change some of the scripting so that If you do not type in the correct password on the first attempt it shuts down your computer.
The original batch is:

cls
@ECHO OFF
title Folder Private
if EXIST "HTG Locker" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Private "HTG Locker"
attrib +h +s "HTG Locker"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%==password goto FAIL
attrib -h -s "HTG Locker"
ren "HTG Locker" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Private
echo Private created successfully
goto End
:End


I created a basic shutdown program, shutdown -s -t 1 -c "Virus Upload Begun"
The shutdown program works great by itself but I cannot get the program to start with a failed password attempt.
Here is what I have:

cls
@ECHO OFF
title Folder Private
if EXIST "HTG Locker" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Private "HTG Locker"
attrib +h +s "HTG Locker"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%==password goto FAIL
attrib -h -s "HTG Locker"
ren "HTG Locker" Private
echo Folder Unlocked successfully
goto End
:FAIL
start "C:\Windows\System32\shutdown.exe"
goto End
:MDLOCKER
md Private
echo Private created successfully
goto End
:End

Any and all help is appreciated!


My System SpecsSystem Spec
.
03 Sep 2012   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

Welcome to the Seven Forums.

replace
start "C:\Windows\System32\shutdown.exe"
with
shutdown -p

don't lie or joke about a virus
someone might just yank the power/battery plug from the computer and damage stuff
My System SpecsSystem Spec
04 Sep 2012   #3
schnabel14

Windows 7 Home Premium 32bit
 
 

I can't believe it was that easy. Thanks for your help. and yes i understand where you are coming from about the virus. Thanks!
My System SpecsSystem Spec
.

Reply

 How do I write a batch to run a .exe program




Thread Tools





Similar help and support threads
Thread Forum
How can I write a batch file that opens a file in a program?
I wrote this batch file which does what I want it to do so far. @echo off "C:\Users\xxxxxx\Documents\HideTaskbar\HideTaskbar.exe" "C:\Program Files (x86)\VideoLANold\VLC\vlc.exe" "C:\Users\xxxxxx\Documents\HideTaskbar\ShowTaskbar.exe" exit
General Discussion
Serial read/write in batch file?
Hello all. I'm trying to write a request to COM2 and capture the answer. My device is 19200 baud 8/1 non parity. Using a freeware terminal called termite I can send the hex instruction and receive the answer, as verified in HHD serial monitor. My batch file looks like this: MODE COM2:...
General Discussion
How do I write batch file to delete thousands of files
Was infected by the matsnu1 virus recently which encrypes and locks all your data files. Got all my files back by running matsnu1decryp.exe You need an original clean file before the virus struck for it to work out how to decrypt all your other files does does save the day. Down side is that you...
Software
I want to write a batch file to get the DNS numbers behind a router.
I do a lot of internet troubleshooting and would like to put a simple batch file in customers computers that will let me see their DNS numbers when they are using a router. I currently do this from a command prompt for Comast: nslookup set type=ns comcast.net It's been years since I...
Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 02:45.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App