کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی
کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

کلینیک فوق تخصصی اکسس ( کاربرد vba در اکسس )

به اشتراک گذاری اطلاعات کسب شده در اکسس از سایت آفیس و سایت های تخصصی خارجی

Windows management instrumentations


"winmgmts:"

win32-networkadapterconfiguration

 IPENABLED دارد که دیتا تایپ آن BOOLEAN است و میشود IPADDRESS های فعال که دیتا تایپ String دارد و باید بعد از استفاده از متد ExecutedQuery آبجکت WMI در آن لوپ زده شود.


Set objQuery = objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")


win32-process


کلاس Win32_Pocess فرآیندهایی که در سیستم کاری وجود دارد. متد Terminate دارد که می توانید به اجرای فرآیند خاتمه دهید شامل آیتم هایی است که در لینک مشاهده کنید یکی از آنها Name است می توانید در Select از آن استفاده کنید و فرضا مسیر Excel.Exe را در آن بگذارید و بعد از Set کردن Variable به آبجکت آنرا Terminate نمائید.

Set objQuery = objWMI.ExecQuery("Select * from Win32_Process Where Name= .....")

With objQuery

.Terminate

End With 


win32-logicaldisk

کلاس Win32_logicaldisk شامل اطلاعاتی درباره درایوها است و آیتم هایی دارد مثل گرفتن سریال نامبر

VolumeSerialNumber


win32-diskdrive

کلاس Win32_Diskdrive شامل اطلاعات درایوها ست و آیتم هایی دارد مثل SerialNumber که لوپ زده میشود و مقدار را بدست می آوریم.

Set ColItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_DiskDrive") Dim i As Integer 

'For Each ObjItem In ColItems


win32-networkconnection


Get MACAddress win32-networkadapter


Get MACAddress win32-networkadapterconfiguration

IPEnabled / IPAddress  / MACAddress


Win32_OperatingSystem

SerialNumber

Method : Reboot ( Shut & Restart )



API : 

nf-fileapi-getvolumeinformationa


----------------------------------------

Get serial number for hard disks

wmic diskdrive get serialnumber

Example:

c:\>wmic diskdrive get serialnumber
SerialNumber
FR3AG13032430BC13S

Get serial number for mother boards

wmic baseboard get serialnumber


See also get-disk-drive-information-in-windows-10-with-this-command/amp/


MotherBoard  command/Windows/wmic/en-us/wmicBASEBOARD


See Also to minimze or maximize window of application win32/shell/shell-shellexecute

ShellExecute




Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c dir > test.txt"


'Create shell object
Dim objShell
Set objShell = CreateObject("WScript.Shell")
'call Notepad program
objShell.Run "notepad.exe",1,true
MsgBox "I know what you wrote :-)"


"Wscript.Shell"  SendKeys  2b56c24affdd


Wscript.Shell

Run

SpecialFolders("strfoldername")

CreateShortCut

Save


strFolderName : One of the following special folders
(not all are available to all flavors of Windows)
AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates
ShutDown Message " 
Shell "Cmd /c Shutdown -s -t "
shutdown -L


You cannot hide the cmd window with any batch file command. You can launch the batch file from a vbscript and have it run as a background process which hides the cmd window. You could put powershell -window hidden -command "" in your script


"wmic diskdrive get model,serialNumber,index,media > C:\path\to\text.txt"



--------------

I made log table, I have the back-end database on a server, and a few front-end files in the office, and i want to log all the users who access the back-end.

I used the Environ function, it provides me the computer name / user name and anything else i need, but it doesn't show the IP address. The functions I made are working, all I need is to get the IP address..

'ExecQuery

'Win32_NetworkAdapterConfiguration Where
'IPEnabled = True


For Each itm In myobj

  getMyIP = itm.IPAddress(0)
  Exit Function
Next


The "wscript.Network" object

Provides access to the shared resources on the network to which your computer is connected.

Properties :
.UserName
.ComputerName

Methods :
.SetDefaultPrinter
'SetDefaultPrinter "\\research\library1"
.AddWindowsPrinterConnectiob
'AddWindowsPrinterConnection(PrinterPath)
.RwmoveNetworkDrive


GetUser=CreateObject("wscript.Network").UserName

------------

getmac /v /fo csv > T:\macaddresses.csv



"HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\File MRU\Quick Access Display", iShow, "REG_DWORD"

iShow=0 Or 1

'USysRibbon

<backstage>
<tabidMso ="TabRecent" visible="false"/>
</backstage>


ShellExecuteA


عملی را روی فایل خاصی انجام میدهد.


مثل Edit ، Open یا Explore ، Print  و جنس آن از نوع String است.


طبق روش زیر برای ویندوز ۶۴ بیت قبل از فانکشن PtrSafe قرار گرفته بغیر از hWnd که نمایانگر پنجره است و nShowCmd که نمایانگر نمایش پنجره در وضعیت هایی است و از نوع عددی ( Long ) هستند بقیه پارامترها از نوع String می باشند.


#If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#Else
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If



lpFile specifies a document file, lpParameters should be NULL.


اگر lpFile سندی را مشخص کند lpParameters نمی تواند Null باشد.


The flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file,


nShow مشخص میکند چگونه یک اپلیکیشن زمانیکه باز میشود نمایش داده شود اگر lpFile یک فایلی مثل Word را مشخص نماید.


If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. 


اگر تابع درست انجام شود یک مقداری بزرگتر از ۳۲ را برمی گرداند می توانید با Msgbox در اکسس ببینید و اگر Fail دهد یا درست انجام نشود مقداری که علت انجام نشدنش باشد را نشان می دهد فرضا اگر دسترسی به فایل نداشته باشیم.


Example:
FileName = "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office\Microsoft Office Word 2003.lnk"

iRet = ShellExecute(GetDesktopWindow, "open", FileName, vbNullString, vbNullString, vbNormalFocus)
If lRet = 5 Then
    MsgBox "Access Denied" & vbCrLf & "Try pointing directely to the program EXE", , ""
End If



مثال بالا که از سایت گرفته شده نمایانگر این است که اگر دسترسی به فایلی امکانپذیر نبود بعلت محدودیت از طرف ادمین جعبه پیامی را باز کرده و به شما اعلام می نماید. ( GetDeskTopWindow یک هندل است که می بایست تابع آنرا در Module اضافه کنید در اینترنت تابع مورد نظر موجود است حتما از CloseHandle استفاده کنید.


ConstantValueDescription
vbHide0Window is hidden and focus is passed to the hidden window.
vbNormalFocus1Window has focus and is restored to its original size and position.
vbMinimizedFocus2Window is displayed as an icon with focus.
vbMaximizedFocus3Window is maximized with focus.
vbNormalNoFocus4Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus6Window is displayed as an icon. The currently active window remains active.