-
Notifications
You must be signed in to change notification settings - Fork 7
/
WinAutopilotImport.pb
155 lines (126 loc) · 4.47 KB
/
WinAutopilotImport.pb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
;- Compiler
EnableExplicit
;- Variables
Global Event = #Null, Quit = #False
Global Button_ExportAsFile = #Null,
Hyperlink_ExportFolder = #Null,
Text_Serial = #Null,
Hyperlink_SerialNumber = #Null
;- PowerShell Scripts
; None
;- Forms
XIncludeFile "Forms/MainWindow.pbf"
;- Functions
Procedure Clipboard_SerialNumber(EventType)
Define SerialNumber.s = GetGadgetText(Hyperlink_SerialNumber)
SetClipboardText(SerialNumber)
EndProcedure
Procedure BIOS_ReadSerialNumber(Parameter)
; wmic bios get serialnumber
Define Compiler = #Null
Define Output$ = ""
Define Exitcode$ = ""
Define PSExitcode.i = 1
Compiler = RunProgram("powershell.exe",
"-NoProfile -NoLogo -WindowStyle Hidden -Command "+Chr(34)+"& {Get-WmiObject win32_bios | foreach { $_.Serialnumber }}"+Chr(34)+" -ExecutionPolicy Bypass",
"",
#PB_Program_Open | #PB_Program_Hide | #PB_Program_Read)
Output$ = ""
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
Output$ + ReadProgramString(Compiler) + Chr(13)
EndIf
Wend
PSExitcode = ProgramExitCode(Compiler)
CloseProgram(Compiler)
EndIf
If (PSExitcode = 0)
HideGadget(Text_Serial, #False)
HideGadget(Hyperlink_SerialNumber, #False)
SetGadgetText(Hyperlink_SerialNumber, Trim(Output$))
Else
MessageRequester("Error", Output$, #PB_MessageRequester_Error | #PB_MessageRequester_Info)
EndIf
EndProcedure
Procedure Export_HashID_CSV(EventType)
Define Compiler = #Null
Define Output$ = ""
Define Exitcode$ = ""
Define PSExitcode.i = 1
;Compiler = RunProgram("powershell.exe", "-NoProfile -NoLogo -File Scripts/ExportAsCsv.ps1 -ExecutionPolicy Bypass", "", #PB_Program_Open | #PB_Program_Read)
Compiler = RunProgram("powershell.exe",
"-NoProfile -NoLogo -WindowStyle Hidden -File .\Scripts\ExportAs-Csv.ps1 -ExecutionPolicy Bypass",
"",
#PB_Program_Open | #PB_Program_Read)
Output$ = ""
DisableGadget(Button_ExportAsFile, #True)
SetGadgetText(Button_ExportAsFile, "Please wait...")
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
Output$ + ReadProgramString(Compiler) + Chr(13)
EndIf
Wend
Output$ + Chr(13) + Chr(13)
;Debug ProgramExitCode(Compiler)
PSExitcode = ProgramExitCode(Compiler)
Output$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
CloseProgram(Compiler)
EndIf
;MessageRequester("Report from PowerShell", Output$, #PB_MessageRequester_Ok | #PB_MessageRequester_Info)
DisableGadget(Button_ExportAsFile, #False)
If (PSExitcode = 0)
HideGadget(Hyperlink_ExportFolder, #False)
HideGadget(Image_Error, #True)
SetGadgetText(Button_ExportAsFile, "Update Hash ID file")
Else
HideGadget(Hyperlink_ExportFolder, #True)
HideGadget(Image_Error, #False)
SetGadgetText(Button_ExportAsFile, "Export failed - Retry")
MessageRequester("Error", Output$, #PB_MessageRequester_Error | #PB_MessageRequester_Info)
EndIf
;ShowWindow_(MainWindow, #SW_MAXIMIZE)
EndProcedure
Procedure Open_HashID_ExportFolder(EventType)
RunProgram("explorer.exe", "C:\HWID", "", #PB_Program_Open)
EndProcedure
Procedure Import_HashID_Intune(EventType)
Define Compiler = #Null
Define Output$ = ""
Define Exitcode$ = ""
Define PSExitcode.i = 1
;Compiler = RunProgram("powershell.exe", "-NoProfile -NoLogo -File ImportIntune.ps1 -ExecutionPolicy Bypass", "", #PB_Program_Open | #PB_Program_Read)
Compiler = RunProgram("powershell.exe",
"-NoProfile -NoLogo -File .\Scripts\Import-Intune.ps1 -ExecutionPolicy Bypass",
"")
Output$ = ""
;ShowWindow_(MainWindow, #SW_MAXIMIZE)
EndProcedure
;- Initalize Main Window
OpenMainWindow()
SetGadgetText(Text_ComputerName, ComputerName())
SetGadgetText(Text_UserName, UserName())
HideGadget(Image_Error, #True)
HideGadget(Hyperlink_ExportFolder, #True)
HideGadget(Text_Serial, #True)
HideGadget(Hyperlink_SerialNumber, #True)
CreateThread(@BIOS_ReadSerialNumber(), 0)
;- Event Loop
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
If Event = #PB_Event_CloseWindow
End
Else
MainWindow_Events(Event)
EndIf
EndSelect
Until Quit = #True
; IDE Options = PureBasic 6.11 LTS (Windows - x64)
; CursorPosition = 24
; Folding = i
; EnableXP
; DPIAware