PDA

View Full Version : OS_SHELL - Strange results using WMIC



Django
19-11-2014, 17:13
Hello,
When I attempt to create a file containing a list of Windows Hotfixes using the WMIC command, I encounter the following error: Invalid XSL format (or) file name.

If I paste the command that is placed on the clipboard by the script directly into a CMD dialog box, it works fine. Also, if I shorten the command to just
wmic qfe list full /format:htable , this also works. Below is the script.

Hoping someone can help.
Cheers



' Create file containing list of Windows Hotfixes
' using the Windows Management Instrumentation Command (WMIC)
' command. This can produce and HTML file (cmdh) or a TXT file
' (cmdt).

Uses "OS"

Dim wm As String Value "wmic qfe list full "

Dim h1 As String Value "/format:htable > "
Dim h2 As String Value "%USERPROFILE%\hotfix.html"

Dim t1 As String Value "/format:texttablewsys > "
Dim t2 As String Value "%USERPROFILE%\hotfix.txt"

Dim cmdh As String
Dim cmdt As String

cmdh = wm & h1 & $DQ & h2 & $DQ
cmdt = wm & t1 & $DQ & t2 & $DQ
OS_Shell(cmdh, %OS_WNDSTYLE_MAXIMIZED, %OS_SHELL_SYNC)
ClipBoard_SetText(cmdh)
MsgBox(0, cmdh)

Petr Schreiber
19-11-2014, 20:18
Hi Django,

what about this version? It works okay on my PC, feel free to change the style to hidden window...


Uses "OS", "File"

String wm = "wmic qfe list full "

String h1 = "/format:htable > "
String h2 = "%USERPROFILE%\hotfix.html"

String t1 = "/format:texttablewsys > "
String t2 = "%USERPROFILE%\hotfix.txt"

String cmdh = wm & h1 & $DQ & h2 & $DQ
String cmdt = wm & t1 & $DQ & t2 & $DQ

RunCommand(cmdh)

Function RunCommand( sCommand As String )

String tempBat = APP_SourcePath + "temp.bat"

FILE_Save(tempBat, sCommand)

OS_Shell(tempBat, %OS_WNDSTYLE_MAXIMIZED, %OS_SHELL_SYNC)

End Function



Petr

Django
20-11-2014, 15:40
Excellent Petr, Thank you.
I'm still puzzled by the issue I encountered in the original script, but oh well.
Cheers.