How disable and enable usb port via command prompt? - windows

How disable and enable usb port via command prompt? or using batch script ? or using vb script in windows 7?

You can use batch which gives you a couple of options. You can edit the registry key to disable usb devices from being used
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f
To enable change value to 3.
Or you can deny access to the files Usbstor.pnf and Usbstor.inf
cacls %windir%\Inf\Usbstor.pnf /d user
cacls %windir%\Inf\Usbstor.inf /d user
Where user is the user account that you want to deny access for.
To enable use
cacls %windir%\Inf\Usbstor.pnf /p user:R
cacls %windir%\Inf\Usbstor.inf /p user:R
Both commands will need admin rights.
Hope this helps

You can also have a look at devcon command. Available freely on microsoft site, for win7+ windows.

I have the same problem and I use a solution that takes the best of the two previous answers:
1º-We disable the functionality that allow us to detect new external storage devices:
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f
2º-We remove all the drivers of USB devices installed on the PC (This will also eliminate the possibility of using keyboard and mouse, but only momentarily):
devcon.exe remove *USB*
3º- We re-scan the connected USB devices, so that Windows will automatically install the drivers of devices different than external storage (eg Mouse, keyboard ...), thus obtaining the desired result:
devcon.exe rescan
4º- If we want to re-allow the use of external storage devices in our PC, we must use the command:
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "3" /f
PD: Every command will need admin rights

I use USBDeview. See documentation and examples to use it. Easy and works fine

Related

How can i change values in Windows registy without admin permissions

i want to automate something, but it only works if i manually accept the uac window, so i tried to change the registry value with this commads:
c:\Windows\System32\cmd.exe /k c:\Windows\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
But it only works if i run the cmd as administrator. So again i need to accept the uac window to deactivate the uac windows...
Is there a good way to make this with a script ore something like that, or is there a bypass solution? (for automation puroses)
If you want to modify a registry hive without administrative privileges, you have to do it offline1.
To do so, you can boot into WinRE and then use regedit to modify your hives offline. You can also remove your hard disk and put it into another computer where you have administrative privileges and modify it there.
You can find an example here.
1 Offline in this case means, the hives are not mounted. Or in other words, the Windows installation is not running.

Command Line - Turn off Password protected sharing

Trying to turn off the Password protected sharing via command line and having no luck at all.
Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings
Password protected sharing = Off
I have looked at netsh advfirewall firewall
And only been able to configure the option for Turn on file and printer sharing.
No registry or command i have seen online can alter this setting, The only placed i have not fully explored is group polices.
PC's come in to be setup, we use a default set of look & feel with a number of settings changed. It would of been nice to have have the one Bat file configure all. But this is the only stumbling block i have hit.
Windows 7 (POS Ready)
I have seen a similar post on here: How do you pro grammatically Turn Password Protected Sharing on/off in Windows 7
Unfortunately this has not worked for me.
After a long time researching for myself I discovered that as long as you run the command prompt window with admin access the following works:
reg add Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa /v everyoneincludesanonymous /t REG_DWORD /d 1 /f
reg add Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters /v restrictnullsessaccess /t REG_DWORD /d 0 /f
And then you will have to restart your computer (which you can do with shutdown /r).

Windows 10 System settings using CMD

Can you change windows 10 system settings using cmd.
I try to make a batch file that change the Windows settings how i want them.
Eexample : my screen is 100% and i want to make my screen 125% can i use a commannd for that ?
i was just wondering if its possible to change windows user options using a batch file. doesnt matter if its the monitor or other windows settings.
Various Windows settings are controlled by Registry keys. You can find the right key for your particular setting by Google search. As an example, to change DPI scaling to 150%, save this script to test.bat, run from open Admin Cmd Prompt, then re-login:
#echo off
reg add "HKCU\Control Panel\Desktop" /v LogPixels /t reg_dword /d 144
exit /b

Changing Windows 7 Wallpaper Remotely

I am trying to remotely change the wallpaper on about 50 computers that are running Win 7 in a WORKGROUP environment.
I have local admin rights to all of them plus they are running an agent (Faronics) that lets me push .bat .exe .msi .vbs and .ps1 to them remotely.
Just wondering if there was any application that lets me do that remotely or if not, what is the easiest way to get my image to these machines and set it as default wallpaper?
The wallpaper that Windows uses is in the registry under the HKCU\Control Panel\Desktop\Wallpaper key
you just can change it with the REG command.
See REG /? and then try...
reg query "HKCU\Control Panel\Desktop" /v Wallpaper
and
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d D:\my.bmp /f
Replacing the file in the following path C:\Users\[user name]\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg is hit or miss depending upon the other desktop background settings shown on the GUI and file type.
I have been able to successfully replace the file with another .jpg file renamed TranscodedWallpaper.jpg and put in its place but the Desktop doesn't just update by itself.
You have to force it with the Rundll32.exe user32.dll,UpdatePerUserSystemParameters command.
This is also hit or miss. I have had it work several times correctly while physically on the computer but cannot get the computer to do the same remotely.
Still working on a 100% working remote solution to fully answer the question.
You can use intelliadmin network administrator to change the desktop pictures remotely on all computers at once

How do I automatically launch a non-Surface application in Windows Embedded 8?

How do I automatically launch a non-Surface application in Windows Embedded 8?
I want to automatically launch a GUI application on startup in Windows Embedded 8, but I can't figure out how to do it. I've been reading Sean Liming's Professional's Guide to Windows Embedded 8 Standard, and in chapter 8 he describes how to modify the device experience. He names how there is a Windows 8 Application launcher, but for Surface apps only. He also describes a Shell Launcher module, but my app is not a shell. He also mentions a shell he wrote here, but reading through its documentation, it doesn't describe how to automatically launch a program within that shell.
As far as I can tell, he doesn't describe how to automatically launch a non-Surface application anywhere, and Google and Stack Exchange get me no results (it doesn't help that most results come back as merely Windows 8, and not Windows Embedded 8). Or am I mistaken? Is Shell Launcher sufficient to launch a non-shell app? Does the app launched become the "shell", in effect?
Side note: It's probably worth mentioning that the app I want to launch is a Java app. I will be including the module-based Java JRE installer as mentioned in the book, but if there are any other provisos to launching a Java app in WE8S, please comment.
Thanks for your time and feedback!
This works for both Windows Embedded Standard 7 and Windows Embedded 8 Standard:
I normally install Windows Embedded Standard with the standard shell. In WE8S this would be the Metro UI. Once installation and configuration is complete, and your application runs successfully, I use registry entries to modify the application launched on startup.
Custom user-specific shell
As an example, to launch VLC media player as the shell, and play media files in a folder on the d:\ e.g d:\media in a continuous loop, I use the below in a .bat file, running as administrator.
This must be run while logged into the user that will launch the custom shell
Create a new .bat file:
in Windows Explorer, Select "File" -> "New" -> "Text Document"
Rename "New Text Document.txt" to custom_shell.bat
Paste the below into the file
Save the file
Right click the file -> "Run as Administrator"
c:\Windows\system32\reg.exe DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /f
c:\Windows\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d explorer.exe
c:\Windows\system32\reg.exe ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "c:\program files\vlc\vlc.exe -f --loop ""d:\media"""
c:\Windows\system32\reg.exe DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot" /v Shell /f
c:\Windows\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot" /v Shell /t REG_SZ /d "USR:Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
pause
This modifies the shell for the !Current User! (i.e. the logged on user) to launch VLC.exe on logon. (I use reg.exe because some slimmed down installations might not have regedit.exe included)
This means that you can still access the full user interface when logging on as the administrator user (via safe mode if Administrator profile is normally disabled), since the shell for all other users is still the explorer shell.
Launching the explorer shell from within the custom shell
You can still launch the explorer shell with the metro UI when the user with the custom shell is logged on. To launch the explorer shell from the user running the VLC (custom) shell:
Start the task manager (CTRL+SHIFT+ESC)
Click on the "Advanced" button at the bottom of the task manager
Select "File" -> "New Task (Run...)" from the menu bar
Enter "Explorer.exe" (This start the explorer service)
Repeat the above steps again (This will lauch an instance of Windows Explorer)
The Metro UI should be usable then
Java application as a shell
More to the point, in order to run your java app, change the below entry in the above .bat
from:
c:\Windows\system32\reg.exe ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "c:\program files\vlc\vlc.exe -f --loop ""d:\media"""
to
c:\Windows\system32\reg.exe ADD "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d "java [any other JVM options you need to give it] -jar "path\jar-file-name.jar""
If your java app does not include a manifest the above will not work!
Try this (I have not tested this):
java -cp jar-file-name.jar full.package.name.ClassName
Revert to the Explorer (default shell) i.e. Undo user-specific shell
To undo the shell changes for the user i.e. revert back to original settings:
!This must be run while logged into the user with the custom shell!
Create a new .bat file:
in Windows Explorer, Select "File" -> "New" -> "Text Document"
Rename "New Text Document.txt" to default_shell.bat
Paste the below into the file
Save the file
Right click the file -> "Run as Administrator"
c:\Windows\system32\reg.exe DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /f
c:\Windows\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /t REG_SZ /d explorer.exe
c:\Windows\system32\reg.exe DELETE "HKLM\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot" /v Shell /f
c:\Windows\system32\reg.exe ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot" /v Shell /t REG_SZ /d "SYS:Microsoft\Windows NT\CurrentVersion\Winlogon"
c:\Windows\system32\reg.exe DELETE "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /f
pause
User Auto Logon:
You can configure Windows to automatically log onto a specific user profile.
Start > Search > netplwiz
OR [Windows Key + R] > netplwiz
A ‘User Account’ window will open. Highlight the account you want to automatically load when Windows starts.
Uncheck the box above it titled “Users must enter a user name and password to use this computer.”
Click OK.
You will be prompted to confirm the operation by entering your password.
Enter your password to complete the change.
The next time you start up Windows, the user account you selected will automatically be loaded
Things to consider
Play around, but use a test environment if possible
If you can launch the shell, so can someone else. Use the keyboard filter to filter out known key combinations, and create one only you, and perhaps the service technicians will know.
Remove admin rights for the user with the custom shell
Use the Unified Write Filter (or Enhanced Wright Filter/File Based Write Filter). Un-protect only when making changes.
A big THANK YOU to Sean Liming and the work that does - he inspired this.
Mark Böhmer
Windows Embedded Specialist
South Africa

Resources