Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
c95ab3c2
Commit
c95ab3c2
authored
7 years ago
by
Onkar Sutar
Browse files
Options
Downloads
Patches
Plain Diff
Get HDD Serial Number as Worm details
parent
37374f9a
Branches
os_info_onkars
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
diskdetailshelper/gopsutil/disk_windows.go
+11
-11
diskdetailshelper/gopsutil/disk_windows.go
with
11 additions
and
11 deletions
diskdetailshelper/gopsutil/disk_windows.go
+
11
−
11
View file @
c95ab3c2
...
...
@@ -8,7 +8,6 @@ import (
"unsafe"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/coreospackage/logginghelper"
"github.com/shirou/gopsutil/host"
"os/exec"
"strings"
...
...
@@ -194,17 +193,18 @@ func RemovableDriveConnected() (bool, error) {
// GetDiskSerialNumber returns Serial Number of given device or empty string
func
GetDiskSerialNumber
(
name
string
)
string
{
info
,
err
:=
host
.
Info
()
if
err
!=
nil
{
logginghelper
.
LogError
(
"GetDiskSerialNumber Host Info() Err : "
,
err
)
// return ""
}
//
info, err := host.Info()
//
if err != nil {
//
logginghelper.LogError("GetDiskSerialNumber Host Info() Err : ", err)
//
// return ""
//
}
cmd
:=
&
exec
.
Cmd
{}
if
err
==
nil
&&
(
strings
.
Contains
(
info
.
Platform
,
"Windows 7"
)
||
strings
.
Contains
(
info
.
Platform
,
"Windows 10"
))
{
cmd
=
exec
.
Command
(
"wmic"
,
"diskdrive"
,
"get"
,
"serialnumber"
)
}
else
{
cmd
=
exec
.
Command
(
"wmic"
,
"path"
,
"win32_physicalmedia"
,
"get"
,
"SerialNumber"
)
}
// if err == nil && (strings.Contains(info.Platform, "Windows 7") || strings.Contains(info.Platform, "Windows 10")) {
// cmd = exec.Command("wmic", "diskdrive", "get", "serialnumber")
// } else {
// cmd = exec.Command("wmic", "path", "win32_physicalmedia", "get", "SerialNumber")
// }
cmd
=
exec
.
Command
(
"wmic"
,
"path"
,
"win32_physicalmedia"
,
"get"
,
"SerialNumber"
)
var
out
bytes
.
Buffer
cmd
.
Stdout
=
&
out
commandError
:=
cmd
.
Run
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets