9 Commits

Author SHA1 Message Date
ef49a0e618 Delete 'Sysinfo_console.cs'
This was not the right file.
2021-06-29 11:18:48 -04:00
1b4a1dd52b Start of C# rewrite.
#14
2021-06-29 11:17:15 -04:00
16af781a94 Start of C# rewrite. 2021-06-29 11:15:41 -04:00
9170d37d0c Update 'quickrun.bat'
quickrun.bat was not resetting the execution policy. This fixes this.
2021-05-05 17:53:14 -04:00
bf11d64feb Merge pull request 'Add domain to the collected information' (#11) from Add_Domain into master
Reviewed-on: #11
2021-04-28 18:15:33 -04:00
4ff0c92217 Add domain to the collected information 2021-04-28 18:12:28 -04:00
93b2bf9180 Merge pull request 'Run from USB' (#9) from USB_run into master
Reviewed-on: #9
2021-04-28 10:19:10 -04:00
9c16227e91 Run from USB 2021-04-28 10:17:30 -04:00
9161568787 Merge pull request 'Add License' (#8) from Add_license into master
Reviewed-on: #8
2021-04-28 09:58:37 -04:00
4 changed files with 101 additions and 6 deletions

View File

@@ -24,6 +24,18 @@ It currently outputs:
## Quick Run
### From USB Stick
Download the USB_Run.zip latest release from [Releases](https://efrick.ddns.net/git/efrick/Sysinfo/releases).
Unzip and copy the folder to a USB stick.
Click on the file `quickrun.bat`
This will put the output file into the directory it was run from.
### From Web
Copy and past into `CMD`
**[Note:]** must be run from an admin prompt.
@@ -36,11 +48,12 @@ Powershell.exe -command "$current_execution_policy = Get-ExecutionPolicy; Set-Ex
This copies the bat file to a temporary location and runs it with the command switch to write the results to the desktop.
### Powershell Breakout
#### Powershell Breakout
Below is a breakout of the Powershell commands run by the Quickrun above.
```powershell
$current_execution_policy = Get-ExecutionPolicy; Set-ExecutionPolicy Bypass CurrentUser
$current_execution_policy = Get-ExecutionPolicy
Set-ExecutionPolicy Bypass CurrentUser
(New-Object System.Net.WebClient).DownloadFile("https://efrick.ddns.net/git/efrick/Sysinfo/raw/branch/master/sysinfo.ps1", "sysinfo.ps1")
.\sysinfo.ps1 -write_output
rm .\sysinfo.ps1

View File

@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Management;
using System.IO;
using System.Threading.Tasks;
using System.Text;
using System.Reflection;
namespace Sysinfo_Console
{
class Sysinfo_Console
{
public static List<String> System_Information()
{
List<String> all_info = new List<String>();
//Create an object of ManagementObjectSearcher class and pass query as parameter.
ManagementObjectSearcher win32_mos = new ManagementObjectSearcher("select * from Win32_OperatingSystem");
ManagementObjectSearcher ram_mos = new ManagementObjectSearcher("select * from Win32_PhysicalMemory");
Double full_ram = 0;
foreach (ManagementObject managementObject in win32_mos.Get())
{
if (managementObject["Caption"] != null)
{
all_info.Add("Operating System Name: \n" + managementObject["Caption"].ToString());
//Console.WriteLine("Operating System Name : " + managementObject["Caption"].ToString()); //Display operating system caption
}
if (managementObject["OSArchitecture"] != null)
{
all_info.Add("Operating System Architecture: \n" + managementObject["OSArchitecture"].ToString());
//Console.WriteLine("Operating System Architecture : " + managementObject["OSArchitecture"].ToString()); //Display operating system architecture.
}
if (managementObject["CSDVersion"] != null)
{
all_info.Add(managementObject["CSDVersion"].ToString());
//Console.WriteLine("Operating System Service Pack : " + managementObject["CSDVersion"].ToString()); //Display operating system version.
}
}
foreach(ManagementObject managementObject in ram_mos.Get())
{
if (managementObject["Capacity"] != null)
{
//Console.WriteLine(managementObject["Capacity"].ToString());
full_ram += Convert.ToDouble(managementObject["Capacity"].ToString());
}
}
all_info.Add("RAM:\n" + (full_ram / 1073741824) + "GB");
//Console.ReadKey();
return all_info;
}
public static void Display_System_Information(List<String> computer_info)
{
Console.WriteLine("Displaying operating system info....\n");
foreach (var p in computer_info)
{
Console.WriteLine(p);
}
}
public static void Wirte_System_Information(List<String> computer_info, String desktop_path)
{
String file_path = desktop_path + "\\Sysinfo.txt";
File.WriteAllLines(file_path, computer_info);
Console.WriteLine("Writing info to: " + file_path);
//foreach (var line in computer_info)
//{
// File.WriteAllLines(".\\Sysinfo.txt", line);
//}
}
static void Main(string[] args)
{
String current_path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
String desktop_path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Console.WriteLine(current_path + "\n" + desktop_path);
List<String> machine_info = System_Information();
Display_System_Information(machine_info);
Wirte_System_Information(machine_info, desktop_path);
}
}
}

View File

@@ -2,8 +2,5 @@ ECHO off
REM Runs the quick run commands form the readme.md
REM https://efrick.ddns.net/git/efrick/Sysinfo/src/branch/master/README.md#quick-run
REM This must be run from an elevated prompt.
curl https://efrick.ddns.net/git/efrick/Sysinfo/raw/branch/master/sysinfo.ps1 > %userprofile%\AppData\Local\Temp\sysinfo.ps1;
Powershell.exe -command "cd $env:userprofile; AppData\Local\Temp\sysinfo.ps1 -write_output"
del %userprofile%\AppData\Local\Temp\sysinfo.ps1
Powershell.exe -command "$current_execution_policy = Get-ExecutionPolicy; Set-ExecutionPolicy Bypass CurrentUser;$current_path = pwd; .\sysinfo.ps1 -write_output -file_location $current_path.Path;Set-ExecutionPolicy $current_execution_policy CurrentUser"

View File

@@ -57,6 +57,7 @@ function Find-Computer-Info {
#Init array for storing computer's data
$computer_info = @("HOSTNAME:", $cs.Name,
"Domain:", $cs.Domain,
"OS Version:", $computer_os_info.Caption,
"OS Architecture:", $computer_os_info.OSArchitecture,
"Manufacture:", $cs.manufacturer,
@@ -94,6 +95,7 @@ function Show-Computer-Info { # Function writes by default to stdout. If given a
function Find-Computer-Info_7 {
$cs_hostname = wmic computersystem get name
$cs_domain = wmic computersystem get Domain
$os_name = wmic os get Caption
$os_arch = wmic computersystem get SystemType
$cpu_name = wmic cpu get name
@@ -105,6 +107,7 @@ function Find-Computer-Info_7 {
$computer_info_7 = @(
"HOSTNAME:", $cs_hostname[2],
"Domain:", $cs_domain[2],
"OS Version:", $os_name[2],
"OS Architecture:", $os_arch[2],
"Manufacture:", $cs_manufacturer[2],