Skip to main content

Posts

Showing posts with the label Windows

Add a user in command line in Windows and Linux

How to add a user via command line in Windows and Linux?

Adding a user whether in Linux or Windows requires the user have rights to create.

In Windows you must be a member of the administrator or other groups who has the rights to create a user.

In Linux you must be a root or either a member of the sudoers depending on what distro you are using.

In Windows to create  a local user in a Windows client operating system such as Windows 7 or Windows 10.

A one liner command can be issued to create a local user, using the command prompt Window at an elevated mode or administrator mode.

At the command prompt type:

Net user  "username" "password" /add

Net user  << this should be type like that it’s part of the command syntax while username and password, can be any data and of course /add is needed meaning the command is adding a user to the system.

Example: net user spiderbond 007-homeSp!dey /add

Command will add a user name called spiderbond and the password is 007-…

Access denied renaming shared folder

If you are working in a shared active directory environment and has a shared folder that needs to be renamed once in a while.
But every time you want to rename there is always a user who is using the folder and therefore, renaming the folder is denied.
How to rename the folder when the shared folder is always in use?
Automation will come for the rescue in such a scenario.
How to automate renaming the folder?
Task scheduler and a simple batch file can do the task and a life saver.
Here's how to do it:
Of course, disconnect all the open files. Users should shutdown their computers when they went out of the office,
If they don't shutdown, force their disconnection by using the command below:
openfiles /disconnect /o read/write openfiles /disconnect /o no access
Then, rename the folder with the ren or rename command of course.
Syntax is the good old fashioned source folder or path and the new folder name.
If the batch file will be run directly on the server, then the drive letter w…

Find or search files in Windows

Search files recursively using PowerShell or the old good dir command line.
To search using PowerShell:
gci d:\ -recurse | where-object {$_.name -like "g*.txt" }
GCI – a short form for Get-ChildItem Recurse – is to search recursively (folder and sub-folders) G*.txt - * tells the PowerShell to search any document that start with g and don’t care anything that follows it
To do it using the old way via command line, open command prompt and type:
Dir /s d:\ g*.txt
To save the search output just use the “>” redirect operator.
Dir /s d:\ g*.txt > d:\G_filenames.txt
/s - parameter to search recursively (folder and sub-folders)

The search result will be written to G_filenames.txt
In PowerShell to save the search result type:
gci d:\ -recurse | where-object {$_.name -like "g*.txt" } | out-file d:\gxfiles.txt


If you still want the very conventional way of searching.

Minimize all windows folders by pressing "windows key" + "d", win d (press both keys a…

Excel find last row with value in a specific column

1. How to find last row with value using vba in a specific column?

2. How to find last row with value  using vba in a worksheet?

The questions above are entirely two different scenarios.

The first question will find the last row with value in a specific column within the worksheet.

While the second question find the last row with value of the entire worksheet.

The first question is applicable if you need to find the last row in different columns.

Let's say Column 1 or Column A, or Column 2 or Column B etc.

Example code below will find the last row in a specific column via VBA code.

===================
'command Cells(Rows.Count, 1) = find the last row with value in Column 1 for Sheet3

Dim last_row As Integer

last_row = Worksheets("sheet3").Cells(Rows.Count, 1).End(xlUp).Row

Msgbox last_row

'replace 1 with the desired column 
'ex: command Cells(Rows.Count, 7) = find the last row with value in Column 7
===================

If you don't need to specify a worksheet or…

Svchost process in task manager

Svchost.exe contains generic host processes.

If the svchost.exe is accidentally close or intentionally close, then the system might crash or shutdown.

There are times that svchost.exe does consume quite a lot of resources and eats up the memory on the system. Thus, it's quite tempting to close or kill the process.

To kill or close a process forcefully via command line can be done using taskkill command plus the process id.

Ex: Taskkill /pid 1234

How to know exactly which service or process the svchost is running?

To check the pid and the process that svchost is running, type:

tasklist /svc

Tasklist /svc command will display the image name, pid and the services.

Output example for tasklist /svc command:

svchost.exe                   1172 EventSystem, fdPHost, FontCache, netprofm,
                                   nsi, W32Time, WdiServiceHost
svchost.exe                   1200 Appinfo, BITS, Browser, CertPropSvc,
                                   EapHost, IKEEXT, iphlpsvc, LanmanSe…

Domain Computer takes a long time to login

Login process should be quick and fast, so every user will be happy and start the day smoothly.
But not every day is a new year’s day and there are times that things will just go south and some issues will surface.
Enabling verbose login in local group policy will definitely help to troubleshoot which part of the login process the system halts and takes a long time to process.
Folder redirection for some reason will cause an issue that will take time to load the desktop or causes a login issue.
There are quite a lot of reasons why a GPO takes time to process, and causes login issue.
But if a computer or workstation has been working fine and all of a sudden gives a logon issue; no changes has been made on the server or GPO. Then an issue could occur at the workstation or client side.
One solution that might work on this kind of scenario is to open an elevated command prompt and issue this command on the problematic user computer:
Netsh winsock reset

Normally, the command above is issue…

PowerShell copy file, link or folder to users’ desktop

Deploying a shortcut link, file or folders can easily be done via group policy preferences.
Or it can also be done using PowerShell as logon or start up script.
A one liner code snippet to deploy a file, a shortcut links or a folder to user’s desktop.
Copy a file: copy-item "\\shared_folder\files_2be_copied.txt" "c:\users\public\desktop"
Copy a shortcut link to user desktop: copy-item "\\shared_folder\shortcut_file_2be_copied.lnk" "c:\users\public\desktop"
Copy a folder: copy-item "\\shared_folder\folder_2be_copied" "c:\users\public\desktop" -Container -Recurse



================================ Free Android Apps:
Click on links below to find out more:
Linux Android App cheat sheet: https://play.google.com/store/apps/details?id=com.LinuxMobileKit
Multiplication Table for early learnershttps://play.google.com/store/apps/details?id=com.TableMultiplication
Catholic Rosary Guide  for Android:
https://play.google.com/store/apps/details?id=com.my…

PowerShell move matching files in a folder

Requires PS 3.0
This is a two lines code snippet to move matching files in a source folder to another folder.
#==============================

$SourceFolder = "C:\File_monitor_records\"
# Find all files matching *.csv in the folder specified  # Find csv files with 2016 in its filename Get-ChildItem -Path $SourceFolder -Filter *2016*.csv | move-item  -destination C:\File_monitor_archives\2016\

#==============================
-Filter *2016*.csv –adjust or create your own pattern, use regex if necessary
Test the pattern before moving the files to make sure correct files are being moved. Check and double check, to avoid wasting time and effort.
This will just like matching files.

Get-ChildItem -Path $SourceFolder -Filter *2016*.csv


Move files and change file name:
http://quickbytesstuff.blogspot.sg/2015/06/powershell-move-files-and-change-file.html

================================ Free Android Apps:
Click on links below to find out more:
Linux Android App cheat sheet: https://play.google.com/s…

Windows audio disabled and wireless icon showing disconnected

In Windows 7 I encountered an issue showing that “Windows Audio is disabled”, I had checked the device manager audio devices was working fine. I checked the Windows Audio Volume Control, the default speaker is enabled. I checked the “Audio disabled devices”, there was a device that was disabled but cannot enable.

I tried restarting Windows Audio Service but it just doesn’t help. I did some Googling and one of the results points to Microsoft Online Answers Community and one respondent suggested the commands below:

Run commands below at an elevated mode or Administrator mode.

net localgroup Administrators /add networkservice press enter then type:

net localgroup Administrators /add localservice press enter and restart your computer

Link to the original article:
https://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/audio-device-is-disabled/3d49e32d-6c1c-44c8-a7b3-52166a0233b0

After restarting the computer, the audio was working already.

Aside from the Windows Audio is di…

Vbscript send email via Office 365

Sending automated email via Office 365 account requires the use of SSL or in some instances you need to use SSL and TLS both enabled on the script.

Below is an example that works fine using Vbscript.

This is useful if you need to automate email messages via Task Scheduler or Windows event attached to this script, when the event is triggered the script will execute the VBS file and send the message.

Modify the message subject, body and of course, the email domain name, user and password.

Open notepad copy and paste the code, save as "filename.vbs"

The quotes are important when doing save as via notepad or else the file will be save as .txt.

Enjoy! Cheers!

'=======================
Dim xstrAll(), strMessage,intupper()

Set objFSO = CreateObject("Scripting.FileSystemObject")

'Send the mail
SentMail


Sub SentMail

strMessage =  strMessage & "Your other message..."

strTo= "your.office365@domain_account.com" 
strFrom="your.office365@domain_accou…

Hide the taskbar in Windows 10

Windows 10 update changes the way how to hide the taskbar.
The old way was the traditional way of hiding the taskbar just like in Windows XP, by right clicking on an empty taskbar and selecting “properties” and from the properties window there is an option to hide the taskbar automatically.
However, Windows 10 OSes that has  been updated, right clicking the empty taskbar does not show “properties” anymore.  Instead of clicking or finding properties, click on “settings” and on the settings Window, an option to hide the taskbar in desktop mode can be enabled or disabled.
See screens shot below, on how to do it:





================================ Free Android Apps:
Click on links below to find out more:
Linux Android App cheat sheet: https://play.google.com/store/apps/details?id=com.LinuxMobileKit
Multiplication Table for early learnershttps://play.google.com/store/apps/details?id=com.TableMultiplication
Catholic Rosary Guide  for Android:
https://play.google.com/store/apps/details?id=com.myrosar…

Insert a new PCIe graphic card

Inserting a new PCIe graphic card to a custom built-PC, it sounds easy right.
Plug the PCIe graphic card to the PCIe slot on the motherboard; insert DVI, VGA cable or any other input that the graphic card supports.
Then, simply power on the PC and boom, everything will be working. However, the monitor shows a blank screen only.
If the PCIe graphic card has been tested and working well, then try resetting the CMOS or remove the CMOS battery and power on the PC for 5 seconds turn it off and put back the CMOS batt.
Now, turn on again the PC with the cables inserted or plug to the graphic card and if the PCIe card is inserted properly in the slot. Then the monitor will work as per normal. The display will be working fine.
When inserting or troubleshooting the graphic card, it is better to unplug the hard disk. If the monitor has no display, you do not know whether the OS is booting or not. 
In addition, by simply turning off the power, once, the graphic card is working fine. Then you got…