MSv9 Crashes WMIC

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

MSv9 Crashes WMIC

Post by CyberCitizen » Wed Jan 13, 2010 3:57 am

Hi Guys,

I Am Trying To Create A Script That Will Pull The Username From A Networked Machine & Return The Data To A File

When I Try An Run The Script I Get This Error Message Though MSv9
Image

Yet If I Run The Same Command Via The Windows Run Box It Works Ok.

Any Idea Why MSv9 Would Cause This Crash? Does Anyone Have This Issue In The Newer Version Of MSv11? Anyone Else Have This Issue? Note Removed Computer Name Variable & Replaced It With 127.0.0.1

Code: Select all

Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c WMIC /NODE:127.0.0.1 COMPUTERSYSTEM GET USERNAME > %TEMP_DIR%COMTOOLSUsernameOutput.txt
ReadFile>%TEMP_DIR%COMTOOLSUsernameOutput.txt,UsernameResults
MessageModal>UsernameResults
DeleteFile>%TEMP_DIR%COMTOOLSUsernameOutput.txt
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
FIREFIGHTER

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 13, 2010 9:27 am

It is working fine for me in MS11 running on Windows 7.

Any reason why you can't just do:

MessageModal>%COMPUTER_NAME%\%USER_NAME%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Wed Jan 13, 2010 11:36 pm

That would work if I wanted to return the user name the exe is being run on, however this is an addon to a help desk tool written in MSSL. This command is basically meant to call the networked PC and return the logged on user. I tried installing MS again (clean install on another PC) and returned the same error. I am trying to work out if it's cause MS calls the command it's crashing. I don't have any of my older versions to check with so I was wondering if someone with a new version could test.
FIREFIGHTER

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Alternatives

Post by gdyvig » Thu Jan 14, 2010 1:37 am

Hi CyberCitizen,


Perhaps the program will not run under Macro Scheduler. Try the ExecuteFile command. If all else fails, write a script to launch it the same way you do it manually.

Another tool is SysInternals PsLoggedIn.


Gale

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri Jan 15, 2010 12:18 am

Hi gdyvig,

I have tried executing it as a file, however that is not valid for both cmd & wmic.

I am trying to keep this app standalone at present, I mean I could wrap it in a virtual enviro (ThinApp), however I am trying to keep the app single & standalone. Thats why I didn't want to rely on PSLoggedIn.

The command I am executing works ok in a Run dialog (Start > Run), however as soon as I have MS execute the same command I get this error, I am trying to ascertain if its a bug with the version of MS but without another version to test with I am having to ask you guys. Thats why I was hoping Marcus could have a look & test to see if he gets the same issue.

Marcus,

Could you please compile that script into an exe so I can test in our enviro & see if it gives the same result or if it works, if its works then its the version of MS I have, if it doesn't then it might be an issue with MSv9 & XP.
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri Jan 15, 2010 1:09 am

Ok I Have Confirmed That Its An Issue With v9.2.01

I Have Tried Version v11.1.12

The Issue Is No Longer Present.

Looks Like Its A Fault With That Version Of MS.
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Sun Jan 17, 2010 11:46 pm

Sorry for the triple post, however if I didn't it wouldn't show up as a new post for you to read. Marcus advised that v9 is no longer supported, but it does work in v11 for some reason.

I am having an issue with one of my scripts now.

Code: Select all

// COMPILE_OPTS|C:\Documents and Settings\Michael Allen\Desktop\CSU.Com.Tools.v2.9.exe|G:\Icons\TransportSA.ico|CONSOLE=0|INCLUDES=1| /LOGFILE=\dev\nul /NOSYSTRAY /NOSTOPKEY /NOSYSTRAY /LOGFILE=\dev\nul /NOSYSTRAY /HIDE /NOSTOPKEY /HIDE /NOSTOPKEY /LOGFILE=\dev\nul
Let>APP_TITLE=COM Tools v2.9

NumOn

Dialog>COMTOOLS
   Caption=%APP_TITLE%
   Width=353
   Height=193
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Edit=COM,8,8,329,
   Button=SCCM Connect,8,32,105,25,8
   Button=Ping,120,32,105,25,3
   Button=Up Time,232,32,105,25,4
   Button=Network Drive,8,64,105,25,5
   Button=Trumps IP / MAC,120,64,105,25,6
   Button=Brian Enq,232,64,105,25,7
   Button=Kill Knet,8,96,105,25,9
   Button=Comp Manage,120,96,105,25,10
   Button=Logged On User,232,96,105,25,11
   Button=Fix Spoolsv Crash,8,128,105,25,12
   Button=Exit,120,128,105,25,2
   Label=Michael Allen © 2010,232,137,true
   Label=Written By,285,125,true
   Default=SCCM Connect
EndDialog>COMTOOLS


Show>COMTOOLS

Label>ActionLoop
GetDialogAction>COMTOOLS,r
if>r=2,Exit
if>r=3,Ping
if>r=4,UpTime
if>r=5,Map
if>r=6,IPMAC
if>r=7,Brian
if>r=8,SCCMConnect
if>r=9,KnetKill
if>r=10,CompMang
if>r=11,CompUser
if>r=12,SpoolSV
Wait>1
Goto>ActionLoop

SRT>LengthCheck
Length>%COMTOOLS.COM%,Len
If>%Len%=4
Let>COMTOOLS.COM=COM%COMTOOLS.COM%
Else
EndIf
End>LengthCheck

Label>Ping
CloseDialog>COMTOOLS
Gosub>LengthCheck
Let>RP_WAIT=1
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c ping %COMTOOLS.COM% -t -l 1024
Let>RP_WAIT=0
Show>COMTOOLS
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>UpTime
CloseDialog>COMTOOLS
Gosub>LengthCheck
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c systeminfo /s %COMTOOLS.COM% | find "Up Time" > %TEMP_DIR%COMTOOLSUpTimeOutput.txt
ReadFile>%TEMP_DIR%COMTOOLSUpTimeOutput.txt,UpTimeResults
MessageModal>UpTimeResults
DeleteFile>%TEMP_DIR%COMTOOLSUpTimeOutput.txt
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
Show>COMTOOLS
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>Map
Gosub>LengthCheck
Let>RP_WINDOWMODE=3
Run Program>%WIN_DIR%\explorer.exe \\%COMTOOLS.COM%\C$
Let>RP_WINDOWMODE=1
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>IPMAC
CloseDialog>COMTOOLS
Gosub>LengthCheck
//Gets IP Address
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c PING %COMTOOLS.COM% > %TEMP_DIR%IPOutput.txt
ReadLn>%TEMP_DIR%IPOutput.txt,4,IPLine4
MidStr>%IPLine4%,12,15,IPADDRESS
StringReplace>%IPADDRESS%,b,,IPADDRESS
StringReplace>%IPADDRESS%,y,,IPADDRESS
StringReplace>%IPADDRESS%,t,,IPADDRESS
StringReplace>%IPADDRESS%,:,,IPADDRESS
StringReplace>%IPADDRESS%, ,,IPADDRESS

//Gets MAC Address
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run Program>cmd /c GETMAC /s %COMTOOLS.COM% /FO CSV > %TEMP_DIR%MACOutput.txt
ReadLn>%TEMP_DIR%MACOutput.txt,3,Line3
MidStr>%Line3%,2,17,MACADDRESS
MessageModal>COM Number: %COMTOOLS.COM%%CRLF%IP Address: %IPADDRESS%%CRLF%MAC Address: %MACADDRESS%
DeleteFile>%TEMP_DIR%IPOutput.txt
DeleteFile>%TEMP_DIR%MACOutput.txt
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
Show>COMTOOLS
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>Brian
Gosub>LengthCheck
Let>RP_WINDOWMODE=3
MidStr>%COMTOOLS.COM%,4,4,COMNUM
Run Program>C:\Program Files\Internet Explorer\IEXPLORE.EXE http://webapps/brianenq/AssetDetails.asp?asset=COM-%COMNUM%
Let>RP_WINDOWMODE=1
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>SCCMConnect
CloseDialog>COMTOOLS
Gosub>LengthCheck
Let>RP_WAIT=0
IfFileExists>C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin\i386\rc.exe
Run Program>"C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin\i386\rc.exe" 1 %COMTOOLS.COM% \\DTEISMSP01
Let>WW_TIMEOUT=30
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
WaitWindowOpen>Configuration Manager Remote Control*
Wait>0.5
WindowAction>1,Configuration Manager Remote Control*
SetFocus>Configuration Manager Remote Control*
Goto>ActionLoop
Else
MessageModal>SCCM Client Is Not Installed%CRLF%Please Install Client%CRLF%%CRLF%"C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin\i386\rc.exe"
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
Goto>ActionLoop
Endif
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
Goto>ActionLoop

Label>KnetKill
CloseDialog>COMTOOLS
GoSub>LengthCheck
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run Program>cmd /c Taskkill /S %COMTOOLS.COM% /F /IM DM.exe > %TEMP_DIR%Output1.txt
ReadFile>%TEMP_DIR%Output1.txt,Output1
Run Program>cmd /c Taskkill /S %COMTOOLS.COM% /F /IM Interceptor.exe > %TEMP_DIR%Output2.txt
ReadFile>%TEMP_DIR%Output2.txt,Output2
Run Program>cmd /c Taskkill /S %COMTOOLS.COM% /F /IM PAPIHost.exe > %TEMP_DIR%Output3.txt
ReadFile>%TEMP_DIR%Output3.txt,Output3
Let>RP_WINDOWMODE=1
Let>RP_WAIT=0
Let>MSG_HEIGHT=300
Let>MSG_WIDTH=600
MessageModal>Kill Process Output Of DM.exe%CRLF%%Output1%%CRLF%%CRLF%Kill Process Output Of Interceptor.exe%CRLF%%Output2%%CRLF%%CRLF%Kill Process Output Of PAPIHost.exe%CRLF%%Output3%
DeleteFile>%TEMP_DIR%Output1.txt
DeleteFile>%TEMP_DIR%Output2.txt
DeleteFile>%TEMP_DIR%Output3.txt
Show>COMTOOLS
ResetDialogAction>COMTOOLS
NumOn
Goto>ActionLoop

Label>CompMang
Gosub>LengthCheck
Let>RP_WAIT=0
Let>RP_WINDOWMODE=0
Run Program>cmd /c compmgmt.msc /computer=\\%COMTOOLS.COM%
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
Goto>ActionLoop

Label>CompUser
Gosub>LengthCheck
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c WMIC /NODE:%COMTOOLS.COM% COMPUTERSYSTEM GET USERNAME > %TEMP_DIR%COMTOOLSUsernameOutput.txt
ReadFile>%TEMP_DIR%COMTOOLSUsernameOutput.txt,UsernameResults
MessageModal>UsernameResults
DeleteFile>%TEMP_DIR%COMTOOLSUsernameOutput.txt
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
Goto>ActionLoop

Label>SpoolSV
Gosub>LengthCheck
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>MSG_HEIGHT=320
Let>MSG_WIDTH=500
Run Program>cmd /c sc \\%COMTOOLS.COM% stop spooler
Message>Stopping Printer Spooler Service On %COMTOOLS.COM%
Label>SpoolSV1
Wait>1
DeleteFolder>\\%COMTOOLS.COM%\c$\WINDOWS\system32\spool\PRINTERS
IfDirExists>\\%COMTOOLS.COM%\c$\WINDOWS\system32\spool\PRINTERS
Goto>SpoolSV1
Else
Message>Stopping Printer Spooler Service On %COMTOOLS.COM%%CRLF%%CRLF%Deleting Corupt Print Documents On %COMTOOLS.COM%
CreateDir>\\%COMTOOLS.COM%\c$\WINDOWS\system32\spool\PRINTERS
Run Program>cmd /c sc \\%COMTOOLS.COM% start spooler
MessageModal>Stopping Printer Spooler Service On %COMTOOLS.COM%%CRLF%%CRLF%Deleting Corupt Print Documents On %COMTOOLS.COM%%CRLF%%CRLF%Starting Printer Spooler Service On %COMTOOLS.COM%%CRLF%%CRLF%Printer Service Has Been Stopped, Corupt Print Jobs Deleted & Print Service Restored.  If The User Is Still Having Issues, Then Please Attempt Process Manually.
Let>RP_WAIT=0
Let>RP_WINDOWMODE=1
ResetDialogAction>COMTOOLS
NumOn
Show>COMTOOLS
Goto>ActionLoop
Endif

Label>Exit
CloseDialog>COMTOOLS
NumOn
Thats the script, when I run the button for username I get the username returned with other data from the script, I can't work out why.

Username result when I ran it.

Code: Select all

UserName        
DTUP\lorraines  
S.COM% /FO CSV > %TEMP_DIR%MACOutput.
I cant work out why the script reads part of the MAC Address Label when its run, I couldn't see any loops that would cause it.

The output for the username part shows invalid characters in MS, but not in notepad when the file is written.

Any help would be greatly appreciated.
FIREFIGHTER

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jan 18, 2010 8:12 am

I didn't say v9 is no longer supported. I said it is currently not maintained. I also said I don't see why that code would have failed in v9 but worked in v11, as nothing has changed regarding the functions in question - notably the Run command.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
CyberCitizen
Automation Wizard
Posts: 724
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Mon Jan 18, 2010 10:51 am

Hey Marcus,

Sorry missinterupted your response. Sorry about that. Any idea why I might be having issues with that above script.
FIREFIGHTER

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts