I recently had an issue running a batch file using a UNC path and discovered that UNC paths are not always supported. This failed in the following line.
ForFiles /p "\\Server\folder\username\SQLBackups" /s /d -13 /c "cmd /c del /q @file"
The solution was to use PUSHD and POPD as shown here
:: Create a temporary drive letter mapped to your UNC root location
:: and effectively CD to that location
pushd \\Server\folder\username
:: Do your work
ForFiles /p "SQLBackups" /s /d -13 /c "cmd /c del /q @file"
:: Remove the temporary drive letter and return to your original location
popd
Explained here: windows - How to run batch file from network share without "UNC path are not supported" message? - Stack Overflow
You can upload documents to SharePoint libraries using the Object Model or SharePoint Webservices.
Upload using Object Model:
String fileToUpload = @"C:\YourFile.txt";
String sharePointSite = "http://yoursite.com/sites/Research/";
String documentLibraryName = "Shared Documents";
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File not found.", fileToUpload);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
// Prepare to upload
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
// Commit
myLibrary.Update();
}
}
This resource is priceless! © 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. - Thank You! I have pasted the matrix here incase this link ever disappears.
Forms: Refer to Form and Subform properties and controls
For these examples:
Mainform is the name of the top level form
Subform1 is the name of the subform CONTROL on mainform
Subform2 is the name of the subform CONTROL on the 1st subform.
If you are on |
|
|
Main form |
Sub 1 |
To refer to a form property, like RecordSource |
|
|
On Mainform |
Me.RecordSource |
Me.Parent.RecordSource |
On Sub 1 |
Me!Subform1.Form.RecordSource |
Me.RecordSource |
On Sub 2 |
Me!Subform1.Form!Subform2.Form.RecordSource |
Me!Subform2.Form.RecordSource |
To refer to a control |
|
|
On Mainform |
Me!ControlName |
Me.Parent!ControlName |
On Sub 1 |
Me!Subform1.Form!ControlName |
Me!ControlName |
On Sub 2 |
Me!Subform1.Form!Subform2.Form!ControlName |
Me!Subform2.Form!ControlName |
To refer to a control property, like Enabled |
|
|
On Mainform |
Me!ControlName.Enabled |
Me.Parent!ControlName.Enabled |
On Sub 1 |
Me!Subform1.Form!ControlName.Enabled |
Me!ControlName.Enabled |
On Sub 2 |
Me!Subform1.Form!Subform2.Form!ControlName.Enabled |
Me!Subform2.Form!ControlName.Enabled |
To refer to a subform control property, like SourceObject |
|
|
On Mainform |
N/A |
N/A |
On Sub 1 |
Me!Subform1.SourceObject |
N/A |
On Sub 2 |
Me!Subform1.Form!Subform2.SourceObject |
Me!Subform2.SourceObject |
|
|
|
|
If you are on |
|
|
Sub2 |
Not in these forms |
To refer to a form property, like RecordSource |
|
|
On Mainform |
Me.Parent.Parent.RecordSource |
Forms!Mainform.RecordSource |
On Sub 1 |
Me.Parent.RecordSource |
Forms!Mainform!Subform1.Form.RecordSource |
On Sub 2 |
Me.RecordSource |
Forms!Mainform!Subform1.Form!Subform2.Form.RecordSource |
To refer to a control |
|
|
On Mainform |
Me.Parent.Parent!ControlName |
Forms!Mainform!ControlName |
On Sub 1 |
Me.Parent!ControlName |
Forms!Mainform!Subform1.Form!ControlName |
On Sub 2 |
Me!ControlName |
Forms!Mainform!Subform1.Form!Subform2.Form!ControlName |
To refer to a control property, like Enabled |
|
|
On Mainform |
Me.Parent.Parent!ControlName.Enabled |
Forms!Mainform!ControlName.Enabled |
On Sub 1 |
Me.Parent!ControlName.Enabled |
Forms!Mainform!Subform1.Form!ControlName.Enabled |
On Sub 2 |
Me!ControlName.Enabled |
Forms!Mainform!Subform1.Form!Subform2.Form!ControlName.Enabled |
To refer to a subform control property, like SourceObject |
|
|
On Mainform |
N/A |
N/A |
On Sub 1 |
N/A |
Forms!Mainform!Subform1.SourceObject |
On Sub 2 |
N/A |
Forms!Mainform!Subform1.Form!Subform2.SourceObject |
Delete Files Older Than X Days with ForFiles Command
You can quickly delete files older than X days with ForFiles Command. Follow the given steps below to use CMD delete files older than x days:
Step 1. Left-click the Windows main menu and search for Command Prompt. Right-click the result and select the "Run as administrator" option.
Step 2. Type in ForFiles /p "C:\path\to\folder" /s /d -X /c "cmd /c del /q @file" to delete files on Windows that haven't been modified in the last X days and press Enter. In the command, change "C:\path\to\folder" specifying the path to the folder you want to delete files and change /d -X to select files with a last modified date.
ForFiles command breakdown
/p - indicates the pathname to start searching.
/s - instructs ForFiles to search inside subdirectories.
/d -specifies the last modified date for a file.
/c - instructs ForFiles to execute the command (must be wrapped in double quotes). The default is "cmd /c del @file".
/q -allows deleting folders without requiring confirmation.
It is possible to have 3 states when it comes to OneDrive files.
- Always available
- Locally available
- Online-only
See this link for full details: Set Files On-Demand states in Windows - SharePoint in Microsoft 365 | Microsoft Learn
I'm backing up some files that would fill up the C drive so each time I backup a file I unpin it. My OneDrive can hold 5TB so now I can keep lots more data when unpinned.
This is an example of how to unpin locally and save space. This is excellent in batch files for multiple files/folders.
attrib +u "C:\Users\[username]\OneDrive - [Company Name]\[FolderName]\*.*"
This can also be accomplished by using the right click menu in Windows Explorer.

This is how to get the Max ID and the Row Count for all tables in a SQL Database. It's a good way to check that things look OK!
The MaxValues should not be wildly, more than the row count unless you know that rows have been deleted constantly, like the use of a temp table for example.
SELECT DISTINCT
SchemaName = SCHEMA_NAME(CAST(OBJECTPROPERTYEX(sc.object_id,'SchemaId')AS INT))
,ObjectName = OBJECT_NAME(sc.object_id)
,ColumnName = sc.name
,DataType = TYPE_NAME (sc.system_type_id)
,MaxValue = sc.last_value
,NoOfRows = p.rows
FROM sys.identity_columns sc
INNER JOIN
sys.partitions p ON sc.object_id = p.OBJECT_ID
WHERE OBJECTPROPERTYEX(sc.object_id,'IsTable') = 1
AND SCHEMA_NAME(CAST(OBJECTPROPERTYEX(sc.object_id,'SchemaId')AS INT)) LIKE 'dbo'
ORDER BY MaxValue DESC, ObjectName
I was adding e-mail code to my ASP.NET Core MVC web app and got this error when trying to send an e-mail using my O365 account.
The remote certificate is invalid according to the validation procedure.
The solution was to add the following routine.
private bool RemoteServerCertificateValidationCallback(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
//Console.WriteLine(certificate);
return true;
}
Then call it from the e-mail code like this.
//Added this line here
System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteServerCertificateValidationCallback);
SmtpClient smtp = new SmtpClient();
So altogether it looks like this.
private void sendAMail(String toAddress, String messageBody)
{
String msg = "Sending mail to : " + toAddress;
MailMessage mail = new MailMessage();
mail.To.Add(toAddress);
mail.From = new MailAddress("from@mydomain.com");
mail.Subject = "Subject: Test Mail";
mail.Body = messageBody;
mail.IsBodyHtml = true;
//Added this line here
System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteServerCertificateValidationCallback);
SmtpClient smtp = new SmtpClient();
smtp.Host = "myhostname.com";
smtp.Credentials = new System.Net.NetworkCredential("sender@sample.com", "");
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.Send(mail);
}
private bool RemoteServerCertificateValidationCallback(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
//Console.WriteLine(certificate);
return true;
}
I found the solution here: c# - "The remote certificate is invalid according to the validation procedure." using Gmail SMTP server - Stack Overflow
I went to run a PowerShell script today and I got this error message "cannot be loaded because the execution of scripts is disabled on this system." It worked previously so I was confused as to why this happened. Maybe a Windows update forced this!
It turns out that you have to execute the PowerShell command "Set-ExceptionPolicy RemoteSigned" and Choose Y for Yes when prompted. This all worked again.
I found the solution here: windows server 2008 r2 - PowerShell says "execution of scripts is disabled on this system." - Stack Overflow
When you share your folders on Windows 10/11/2022 etc. Sometimes the VLC App on your TV will not see these folders. You have to enable the SMB Server/Client features ON. This is what I had to do in order for the Shared Folders to appear in the VLC App.

Note too that I had issues connecting to the Domain Controller. I used the following format to create a link. smb://yourUsername:Password@192.168.x.x Then I had to open the link and go back twice on the Firestick remove to get into the folder!
I followed this link: VLC Network Sharing Not Working : r/VLC (reddit.com)
If you Turn on Network Discovery, click Save Settings, then review it again and it's Off again then you need to check the following 4 Services. Set them to Automatic and then start the Services. You'll hopefully find that turning on Network Discovery now stays on!!

For network discovery, it's a common issue.
Open Services and make sure the following services are all running:
- DNS Client
- Function Discovery Resource Publication
- SSDP Discovery
- UPnP Device Host
After that turn network discovery on again and it should stay enabled.