I would need to start a batch script at boot before the user to log in with his credentials.
How could I do?
Thank you all
You can take a look at this How to launch a program before the shell (Explorer) starts.
If you want to start an application before the shell starts, you can add a value to the Userinit value in the registry. In this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
There is a value named Userinit. Change it so your program is run before userinit.exe. For example, to start notepad before the shell/everything else is initialized:
C:\WINDOWS\system32\notepad.exe,C:\Windows\system32\userinit.exe
Use commas to separate the programs that should be started.
So the same thing for your batch file just add the absolute path instead of the notepad example
There's 2 keys that you can edit from the local registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
If HKLM (HKEY_LOCAL_MACHINE) is modified it will affect the entire machine, so the batch file will run no matter who logs in, while HKCU (HKEY_CURRENT_USER) will only affect the currently logged in user when the registry is modified. You can also add, modify or verify the current existance of either of the above keys from your batch file, just open a command prompt and type REG /? to view available commands.
If you can edit the system's registry, you can run regedit.exe and add browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices. Add a new string value, with an arbitrary name, and the full batch path as value.
I think this will be executed every time Windows is booted. Not sure about if it will be run after awakening from an hibernation period.
Not to be mistaked with HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, which happens every time any user logs in (thanks to Harry Johnston), or HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, which happens every time a certain user logs in.
Related
I know you can use tsdiscon.exe and tscon.exe to connect to a user account via the command line.
I want to write a simple batch file to accomplish this, so I can have a shortcut on my desktop that will quickly and easily login to another user account on this system.
I share this computer with my in-laws, and they are not very computer literate. Currently there are many steps in switching to their account, and I want to make it more streamlined for them.
It's been awhile since I've written a batch file, but I am sure there is a way to run a simple IF/THEN statement, that would check to see if the user is logged in, then either log them in with the given credentials, or switch to that users profile.
I want to know the syntax to make this happen, so I can put the .bat file on the desktop for them to click on.
Is this possible?
Logging out to your account? Suppose impossible.
Suppose your user is usr1 and you save your batch file to, say, your desktop.
Then, by running this batch file, you run it as usr1.
If your batch file contains the log out statement, it therefore ends the user account, therefore terminating the batch file, thus not being able to run the batch file successfully.
However, switching to a different account could be possible.
Try this out, if it works.
Essentially, you're doing the following:
#echo off
taskkill /IM explorer.exe /F
runas /user:COMPUTERNAME\ACCOUNTNAME explorer.exe
(Replace COMPUTERNAME and ACCOUNTNAME with the current computer name and account name (i.e. C:\Users\ACCOUNTNAME) of your in-laws account)
If that's not what you wish, then, sorry, I can't help you.
The batch script I previously mentioned here
Just give your machine a simple name customise one line in script. Test from command prompt:
fus
If it works with win10 you should be able to create two shortcuts with commands:
fus.bat 1
and
fus.bat 2
I am currently using a program called USBDeviewer for auditing purposes. Basically what it does is it gets a list of USB devices that were used on a particular PC. The program can create a log file but you have to do it manually. The keyboard command to save a log file is ctrl+A to select all devices and then ctrl+S to save. After you select save you are prompted to enter a filename and location to save it.
I need a batch script that will automatically run this program and save the information on the log file to a folder automatically without any human intervention such as typing in the name (it needs a different name every time, perhaps the filename can include a different date every time).
This is a simple script but I am not familiar with batch scripting so any help would be appreciated.
Save Command-Line Options for usbdeview.exe
/stext Filename : Save the list of all USB devices into a regular text file.
#echo off
set Log=c:\temp\logfile.txt
usbdeview.exe /stext %Log%
I realize this might be a very basic question but I am slightly new to working with batch.
I am trying to use delprof to delete user profiles off multiple remote computers. I have Delprof.exe saved and can run it from a cmd window to put in different required arguments such as "/p /d:30". I can have my batch file run the application using the start command but it quickly closes the window.
I need to have delprof run from the batch but be interactive so it can prompt me with what profiles it has found and if I want to delete them. Basically Im trying to use this so I dont need to enter the arguments every time. I want it to be one click on the batch file and it will pop up with the profiles found and ask me which ones it should delete.
You are not clear on exactly what you want. But omitting start will probably do what you want. Which is run delprof as if you typed it at command line.
If not see the set /p command.
set /p remote=Enter Computer Name
delprof /c:\\%remote%
I have the following script which is setup as a task to automatically move a file to a mapped network drive. The problem is that this only works when a user is logged in and has an active Windows session open. However, if the user is logged off these backups wont happen as I believe it cannot find the network drive. This is running on a Windows 2003 Server. Is there anyway to alter the script to make sure it can connect to the networked drive while no active sessions are open?
The process I am using is to move the file, then delete the file to clear up hard-drive space, then a .exe is run to empty the recycling bin.
#echo off
move C:\StarshipBackup\*.* Z:\StarshipDataBackup
del C:\StarshipBackup\*.* /F /Q
C:\emptyrecycle.exe
You can mount the drive in the batch file. Add this before your move command:
net use z: \\yourserver\sharename
Of course, you need to make sure that the account the batch file runs under has permission to access the share. If you are doing this by using a Scheduled Task, you can choose the account by selecting the task, then:
right click Properties
click on General tab change account under
"When running the task, use the following user account:"
That's on Windows 7, it might be slightly different on different versions of Windows.
I need my application installer set the program to auto-startup for all users.
Then each individual user should be able to modify this option without affecting others.
Currently I write to HKLM/../Run with installer, which acomplishes the first task.
But then I can't disable autorun for current user, because deleting th HKLM/../Run entry would disable it for everybody.
Is there a way to do that, without using shortcuts in Autostart folder?
start it for all users always but check a configuration variable in HKLU to see if it should exit immediately
Any reason not to use the HKCU Run key in the first place?
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]