|
-
Apr 27th, 2007, 05:14 AM
#1
Thread Starter
Lively Member
API in VBS?
Is there any way to use Win32 API Functions in VbScript?
Just curious.
-
Apr 29th, 2007, 05:18 AM
#2
Junior Member
Re: API in VBS?
No you can't as far as i am aware.
-
Apr 30th, 2007, 11:28 AM
#3
Member
Re: API in VBS?
Actuall you can create the object using it's ref name...ie Scripting.FilesystemObject = some dll... same applies for most dlls
-
May 27th, 2007, 05:08 AM
#4
Thread Starter
Lively Member
Re: API in VBS?
Could you give an example of doing that, with a function. Just anything as an example, like showwindow, or shellexecute.
-
Jun 14th, 2007, 10:05 AM
#5
Thread Starter
Lively Member
-
Jun 21st, 2007, 07:28 PM
#6
Hyperactive Member
Re: API in VBS?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|