Showing posts with label info. Show all posts
Showing posts with label info. Show all posts

Saturday, June 12, 2021

Info: Getting network shares library with C#

Goal: to get a list of available shared folder names given a remote server name. 


1. I believe this uses the user that is logged into the site. https://www.codeproject.com/Articles/2939/Network-Shares-and-UNC-paths

This was super easy to set up.


2. This is what I wrote if logging in with a specific user:

ManagementPath path = new ManagementPath();

            ManagementClass shares = null;

            ConnectionOptions co = new ConnectionOptions();

            co.Username = "login";

            co.Password = "password";

            co.Impersonation = ImpersonationLevel.Impersonate;

            path.Server = FolderPath; //"devaappwebec01"; // use . for local server, else server name

            path.NamespacePath = "root\\CIMV2";

            path.RelativePath = @"Win32_Share";

            ManagementScope scope = new ManagementScope(path, co); // use (path) for local binds

scope.Connect();

ManagementObjectSearcher worker = new ManagementObjectSearcher(scope,

            new ObjectQuery("select Name from win32_share"));

            ManagementObjectCollection moc = worker.Get();

 



Wednesday, May 5, 2021

Info: Find my system's network folder access' user (wmic, gwmi)

 I am wrote a tool to move objects from one server to another. To do this, I use network folders. This is a web tool so I created a local user on each machine that I need access to then created a share folder giving access to my local user.

Problem

While troubleshooting on my development system, my current login user sometimes is used to access the network folder instead of the userid that I wish to use. This occurs sometimes if I use Windows Explorer to check for files before I launch my tool. If my domain account has access to the network folder, this sets my current user account to the network folder. If it does not, then none is set. This was confusing because I was able to access certain folders but not others.


My Solution

I needed a way to see what user account is used to access the network folders. The following are a couple commands that I found that were useful to me.

1. wmic netuse get remotename,username

2. gwmi -Query 'Select LocalName, RemoteName, UserName from Win32_NetworkConnection'


#2 requires powershell to execute


Additional Info

Here are a couple other commands from the page that I didn't need but may be useful to others or my future self.

1. wmic netuse where LocalName="Z:" get UserName /value

2. gwmi -Query 'Select * from Win32_NetworkConnection' | Select-Object LocalName, RemoteName, UserName, ConnectionState | Sort-Object LocalName | ft -auto

3. rundll32.exe keymgr.dll, KRShowKeyMgr



Reference

https://stackoverflow.com/questions/9037503/determine-domain-and-username-used-to-map-a-network-drive

Wednesday, October 8, 2014

Info: Whirlpool wtw8900bc0 Modified Energy Factor, 2.5

I was helping someone fill out a rebate for a new washer and got stuck on the part to fill in the Modified Energy Factor (2.5 for this washer). This turned out to be more of a hassle than I thought. I even went through the manual (although I did just skim through it because it was primarily an instruction manual). Searching did not turn up the model number. After truncating the model number, I did find one site with the information.


Reference

http://www.reviews-washer-dryer.com/wtw8900bc.html
http://www.whirlpool.com/webapp/wcs/stores/servlet/WHRORNAjaxCatalogSearchView?storeId=10211&catalogId=10561&langId=-1&beginIndex=0&searchTerm=wtw8900bc