How can I write a batch file to run a specific command? - batch-file

I'm trying to make a batch file that will run the following command:
control name Microsoft.Personalization page pageWallpaper
How do I do this?
EDIT: I should be more specific. I know how to create a batch file but all I have written in the file is the code above, which just flashes a window and then does nothing.

The following should do what you need:
#echo off
control /name Microsoft.Personalization /page pageWallpaper
The syntax of control.exe requires the slashes before name and page.
Source: Add classic personalization menu in Windows 10 build 10074
Also, Command Line Commands for Control Panel Applets helped lead me to the answer.
I started by googling "windows control.exe command line options".
You know how to create batch files, but if you have any trouble putting the code above into a batch file and running it, and cannot figure out how, please let me know.
This works for me, running:
C:\bin> ver
Microsoft Windows [Version 10.0.14393]
Hope it works for you!
Regards,
Lud nom

Related

How do I make a batch file that opens Task Manager?

So i have been looking for this on this website and cannot seem to find it so im asking you how to do it
If you are looking to display a list of processes from the command prompt you can use TaskList.exe if you are looking to just open the windows Task Manager you can use TaskMgr.exe
For standard batch file you would just use tasklist.exe. If you were using powershell you would use start-process tasklist.exe -nonewwindow.
I created a batch file to start several programs, including Task Manager. I used this code:
cd C:\ProgramData\Microsoft\Windows\Start Menu\Programs
start taskmgr
if this path does not work for you, right click on the task manager app and look at the path in the "properties"
start taskmgr
should work :)
(tested, it works!)
You can use this with a batch file: start "" TaskMgr.exe
I tried it on Windows 11, it worked fine.

How to Create a Simple Batch file for Application Uninstall via CMD?

I am inquiring assistance on creating a simple batch file in order to help field techs at my job remove the Microsoft Exchange Management Console via CMD batch. But for some reason i have been unsuccessful at being to accomplish this.
To my understanding its a matter of changing directories and running a uninstaller.
If i do it manually Run CMD as Admin and copy and paste
cd %ProgramFiles%\Microsoft\Exchange Server\v14\bin\setup.com /m:uninstall
This works flawlessly however when trying to compose it into a batch no go.
#echo off
cd D/ c:\
%ProgramFiles%\Microsoft\Exchange Server\v14\bin\setup.com /m:uninstall
And in theory i am assuming this should do it simple and so i thought but i can not get this thing going. I know i am missing something.
Can someone shed some light on the subject i would be most appreciated.
Thank You.
CD is the command to 'Change Directory'. Try this line to perform the uninstall.
"%ProgramFiles%\Microsoft\Exchange Server\v14\bin\setup.com" /m:uninstall
You need the quotes to handle the spaces in that path. And it is good practice. For future posts remember that it is helpful if you indicate what error or result you are getting.

Setting user name and password to browser from the Batch file

I have created a batch file to open a browser. But I need to know how to interpret the user name and password from the batch file.
Below is my batch file. Can anyone please help?
FYI, I'm just using the normal .bat file (from notepad).
#ECHO ON
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE https://www.myhcl.com/Login/home.aspx
There is no "native" way for a bat file to interact with a window. I would use powershell or VB script for this task but it will be quite a mess.
An easy way is to use AutoIt. It's realy simple and allows you to fully interact with a browser. You could ither use the AutoIt interpreter from within your bat file to manipulate the browser window or just create an au3 or even an exe file that starts the browser and enters the login data.
If you decide to use AutoIt and need help with the script just ask me.

Batch Scripts Will not run on some Windows 7 systems

Any ideas why bat files don't run in some cases?
I have written an interactive batch script (also run as an exe) works on THOUSANDS of systems, HOWEVER, a small subset of systems will NOT launch the script. They open a black box window and then close the script without giving the user the bat menu. I tried the bat file association registry reset which ensures that .bat file association is correct but that didn't help.
What I have tried: bat registry fix (.reg file)
(which didn't seem to help, the script starts but doesn't run)
(I also tested a VERY basic script that printed Hello world which also didn't work)
Thanks everyone for your help. What I found out was:
(1) Reset the command prompt:
http://social.technet.microsoft.com/Forums/windows/en-US/0a74090e-53ce-4642-8dad-0523bfd6c8a2/cant-run-bat-batch-files?forum=w7itproui
(which did not work for me)
(2) In a command prompt I had the users type 'set path' which showed that they were missing /windows/system32/ for one user. So far I had one user put it in and it fixed it. One other user had %systemroot%/system32 which I will have them try adding the path the other way to see if it fixes it. Next I will see if I can just add that to the script.

Remove the close option on a batch file with a command, is it possible?

I was just wondering if there is a code that can remove the "close" button on a batch file. (The minimize and expand buttons isn't important so it is ok if they will be disabled or will stay enabled) That is all. I can't seem to find any answer anywhere.
Thanks.
A batch file is nothing more that a script that another program must execute.
When you double-click a .bat file in Explorer, cmd.exe launches and "opens" the file, running the script. So your question is: can you remove the close button from cmd.exe? Good luck.
You don't want to be doing that. You should make your script NOT show a window to begin with.
If the window is shown, a user can always Ctrl + C to stop the script mid-stream.
There is a number of ways you can make the window hidden (also called "running a script silently"). See the following links:
Run a completely hidden batch file
Solved: HowTo run a batch file without it showing
Eric Helps
Or just google for "batch file silent" or "batch file hide console".
Just a side note: if you have seen this behavior before, chances are that it is not a batch file, but another programming language, and probably not using cmd.exe. C# can let you make a console program app which you can manipulate the title, but even still you cannot change the control buttons on the window. It is simply not within c# or a batch file's scope.

Resources