Using a batch file on Desktop to start shortcut on AllUsersDesktop - batch-file

I use a remote support program to access agent's computers to set them up to work with our dialer.
I use a script via that remote program that adds IE shortcuts to their desktop. To make this script work for any variety of computer setups, the shortcuts are created on the AllUsersDesktop.
I also install a program (called Ventrilo) that creates a shortcut on the specific desktop they are on when I remote into their system.
I would like to add a batch file they can execute that will automatically open the shortcut to Ventrilo and open the IE shortcut on the AllUsersDesktop.
The batch file I have is as follows:
#echo off
start Ventrilo.lnk
start Shortcut.lnk
This opens Ventrilo but not the Shortcut. I am certain it is because the Shortcut is on the AllUsersDesktop, while the shortcut to Ventrilo is not. However, I cannot figure out how to use that start command in conjunction with %AllUserDesktop%

%allusersprofile%\desktop\shortcut.lnk
Type set in a command prompt.

You can start IE by calling start on iexplore, no need to run the shortcut.
start iexplore
Alternatively GoughW's answer should do the trick to.

Make sure you have an end line at the end of your
start shortcut.lnk
in your batch file.

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.

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.

create a bat script to set network directory as a drive(let's say S:) and then calling a bat script within the set directory(somewhere in S)

I run into problems with VM's where i have to manually startup the jobs everytime after the reboot.
I would like a startup bat script to perform the following everytime upon system reboot-
set a network drive as drive s:
(something like what i manually do - "net use s: \network dir name")
and then I call a bat script within the s to do the rest( lets say S:\test\test.bat)
How can i create it all as one bat script? and steps on how can I set it as a startup script on system reboot?
you ask two questions in one.
what is a BAT script?
in its simplest form, a BAT script is just a text file that contains every instruction you type in the command line as a line in the file. So, you just need to create a text file with notepad, fill it with your commands
NET USE s: \\server\sharedfolder
CALL S:\test\test.bat
call it s.bat, place it somewhere in your PATH, and simply invoke it as s in the command line.
how to run such a BAT script at boot?
the simplest (among many others) solution is to create a shortcut to the s.bat file inside the startup folder.
a. Click Start, click All Programs, right-click Startup, click Open.
b. Then locate your s.bat file, ctrl-shift-drag to Startup folder.
You say you are wanting a local batch script to do nothing but NET USE a network share as S:\, then run a remote batch script, e.g., S:\test\test.bat, and you want the local batch script to run every time on system startup?
The share mapping part is actually done for you by the NET USE command - type the following once to have S: available as a mapped drive from now on:
NET USE S: \\server\share /PERSISTENT:YES
Mapped drive S: will be available from now on at startup, without running any other batch script: immediately run your S:\test\test.bat.
To run this batch script - or any other executable - at startup, right-click the script/executable, and drag it to Start Menu, All Programs, Startup folder, and drop it (not on the folder, but in the expanded space just below it where other startup programs are): because you right-clicked, Windows Explorer will prompt you to "Copy here", "Move here", or "Create shortcut here" for the file. Select "Create shortcut here" - the file will run at startup from now on.

Start batch after restart

I'm trying to make a batch start after a restart. Will this work?
This doupdate.bat is stored at a USB drive and is going to be used in many computers.
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /V 1 /D "%~d0\cmd\DoUpdate.bat
So you want it start on startup? Since you cant use Autorun.inf since that needs to be manually clicked to start it up and ever since Win7 it doesnt allow you to change what file it opens on USB, it sounds like your only option is the startup folder. You could write a second batch script to copy the file into the computers startup folder. Here is the code to copy the file into the startup folder as a bat:
C:
copy doupdate.bat "C:\Users\%USERNMAE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\doupdate.bat"
(Note: Thats assuming the bat to move the file is on the USB, and also replace the 'C:' in the code with whatever drive it will be moving to, you cant simply have it move directly to the C drive or CD to it, you have the enter the name since interacting between different drives on batch it tricky, so you have to cd to them a special way first)
But that would only have the file auto-open on restart only on the user that you were currently using when you ran the file.
Also that method requires you to have the file installed to the users computer.
And if you dont want the file to stay on the users computer after its already done its job, simply add this code at the end of "doupdate.bat" for it to delete itself:
del "C:\Users\%USERNMAE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\doupdate.bat"
its as simple as that, that way when it gets run from the Startup folder, as soon as its done with all of its purpose, it will remove itself, and then to re-add it, simply re-run the bat to move the file.
I hope my info helped, and if any of the methods here wont work for your specific bat file just tell me and ill try to find a different method to do it and will edit this post to include that method.
This should work:
copy "doupdate.bat" "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"
Note: Make sure to use this in Windows 10. I am not sure if this will work in Windows 8, 7 but it should also work

How to modify compatibility settings for a file through CMD?

I have a package that gets distributed to multiple machines including a batch file that moves some files into directories. One of the files that gets moved is an executable (.exe). This exe will be ran on a schedule, once the batch file runs for the first time, and moves files accordingly, it is never used again.
If I right click the .exe file > Properties > Compatibility, there is an option under Settings to run this program as an administrator. The application only seems to work when it is ran as an administrator, so I would like to enable this setting whenever the batch file runs.
Is there a way to modify this setting within a batch or via CMD?
What I continue to find in my search, is how to run cmd as admin, or how to add a runas command to the batch so the batch itself is executed as a admin. Since the batch file is only run at setup, and never again, I need a way to set the settings for the exe itself to run as admin.
Based on the info provided in this answer you can add the full path to the registry key Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers with the REG command like so:
Everything should be on one line but for clarity I put each argument on a separate line
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
/v "c:\full\path\to\your\exe\file.exe"
/t REG_SZ
/d "RUNASADMIN"
Above command sets the compatibility flag for all users/system wide. If you want to set it only for the current user use HKCU instead of HKLM.
Do note that setting the value in HKLM subtree requires elevation.
This is tested on Win7 but should work on Vista and Win8.

Resources