Is there any way to use Win32 API Functions in VbScript?
Just curious.
Printable View
Is there any way to use Win32 API Functions in VbScript?
Just curious.
No you can't as far as i am aware.
Actuall you can create the object using it's ref name...ie Scripting.FilesystemObject = some dll... same applies for most dlls
Could you give an example of doing that, with a function. Just anything as an example, like showwindow, or shellexecute.
*Bump*
Function NameFromPing(sIP)
Set Cmd = CreateObject("WScript.Shell")._
Exec("ping -a -n 1 -w 1 " & sIP)
NameFromPing = Split(Cmd.StdOut.ReadAll," ")(1)
End Function
Function NameFromTrace(sIP)
Set Cmd = CreateObject("WScript.Shell")._
Exec("tracert -h 1 -w 1 " & sIP)
NameFromTrace = Split(Cmd.StdOut.ReadAll," ")(3)
End Function
Function nslook(sTargetDomain)
cmdline = "cmd /c nslookup -type=mx " & sTargetDomain
Set Cmd = CreateObject("WScript.Shell").Exec(cmdline)
nslook = Cmd.StdOut.ReadAll
End Function
Function psSID(sHost)
psSID = split(CreateObject("WScript.Shell").Exec( _
"%COMSPEC% /C psgetsid " & sHost).StdOut.ReadAll, vbCrLf)(6)
If Instr(psSID,"No mapping") Then psSID = ""
End Function
Function QBasic(filarg)
' Wrapper for running QuickBasic programs
' QB File MUST have last line: SYSTEM
Dim Sh, FSO, fOut, OutF, Cmd
Set Sh = createobject("WScript.Shell")
Set FSO = createobject("Scripting.FileSystemObject")
fOut = FSO.GetTempName
Cmd = "%COMSPEC% /c qb /run " & filarg _
& " 2>NUL 1>" & fOut
wscript.echo Cmd
Wscript.Quit
Sh.Run Cmd, 0, True
If FSO.FileExists(fOut) Then
If FSO.GetFile(fOut).Size>0 Then
Set OutF = FSO.OpenTextFile(fOut)
QBasic = OutF.Readall
OutF.Close
End If
FSO.DeleteFile(fOut)
End If
End Function
sub RegisterControl(strControlName)
set objShell = CreateObject("WScript.Shell")
sCMD = "regsvr32 /s " & strControlName
rtn = objShell.run(sCMD, 0, true)
wscript.echo strControlName & " " & rtn
end sub
Sub SetServiceState(Svc, State)
' Uses simple shell commands
' state should be: pause, resume, stop, start
CreateObject("WScript.Shell").Run("net " & state & " " & Svc),0,True
End Sub
Sub SetVar_Volatile(VarName,VarValue)
set shell = createobject("wscript.shell")
set envVolatile = shell.environment("volatile")
envVolatile(VarName) = VarValue
End Sub
Sub UnRegisterControl(strControlName)
Set Sh= CreateObject("WScript.Shell")
sCMD = "regsvr32 /s /u" & strControlName
rtn = Sh.Run(sCMD, 0, True)
End Sub