undesirable .bat file side effects in Win7 pro 64-bit

Page 2 of 2 FirstFirst 12

  1. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #11

    OK, here you go.

    Code:
    strDirectory = "c:\users\<UserName>\documents\pingresults\"
    strFile = "pingresult.txt"
    strIP = "173.194.67.94"
    Const WriteMethod = 8
    Set objFSO = CreateObject ("Scripting.FileSystemObject")
    If objFSO.FolderExists (strDirectory) Then
    Set objFolder = objFSO.GetFolder (strDirectory)
    Else
    Set objFolder = objFSO.CreateFolder (strDirectory)
    End If
    If objFSO.FileExists (strDirectory & strFile) Then
    Set objFolder = objFSO.GetFolder (strDirectory)
    Else
    Set objFile = objFSO.CreateTextFile (strDirectory & strFile)
    End If
    Set objFolder = nothing
    set objFile = nothing
    Set objTextFile = objFSO.OpenTextFile (strDirectory & strFile, WriteMethod, True)
    objTextFile.WriteLine (" ")
    objTextFile.Close
    Set objTextFile = objFSO.OpenTextFile (strDirectory & strFile, WriteMethod, True) 
    wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strIP & "'"
    Set objWMIService = GetObject ("winmgmts://./root/cimv2")
    Set objPing = objWMIService.ExecQuery (wmiQuery)
    For Each objStatus in objPing
    strPingResult ="True"
    If IsNull (objStatus.Statuscode) Or objStatus.Statuscode <> 0 Then strPingResult = "False"
    objTextFile.WriteLine (strIP)
    objTextFile.WriteLine (strPingResult)
    objTextFile.Close
    Next
    Adapt the initial variables to suit your needs. They should take the format shown.

    strDirectory This is the directory where the results file is located.
    strFile This is the name of the results file. Don't forget to include the .txt suffix.
    strIP This is the IP address.
      My Computer


  2. Posts : 5
    win 7 64-bit
    Thread Starter
       #12

    Cool Dwarf! Thank you! I got it to work...and thanks for the template that I can expand on.

    So my last issue is writing a script to simulate a small mouse movement, i.e. 2-3 pixels, periodically.

    I am aware of AutoIt and am looking into it. I am wondering if there is another approach?

    -John
      My Computer


  3. Posts : 10,485
    W7 Pro SP1 64bit
       #13

    Ztruker said:
    Does you scheduled task launch a batch file? You don't show the action tab.
    Not that you were talking to me... but:



    Am I missing something in the OP's request?
      My Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #14

    threejeeps said:
    ........Is there a way using a VB script to do a ping of a IP address and send the results into a file?.......
    I'm not sure if you had the same requirement of hiding the command prompt window on this request too, but if the actions/settings shown in the video that I posted above do indeed hide the command prompt window for you then a simple batch file with

    ping google.com > c:\users\username\foo\pingout.txt

    or

    ping 74.125.227.135 > c:\users\username\foo\pingout.txt

    should do what you want

    undesirable .bat file side effects in Win7 pro 64-bit-ping2file.jpg
      My Computer


  5. Posts : 10,485
    W7 Pro SP1 64bit
       #15

    threejeeps said:
    Cool Dwarf! Thank you! I got it to work...and thanks for the template that I can expand on.

    So my last issue is writing a script to simulate a small mouse movement, i.e. 2-3 pixels, periodically.

    I am aware of AutoIt and am looking into it. I am wondering if there is another approach?

    -John
    What is the end goal of this mouse movement? To prevent screensaver or power settings from kicking in?
      My Computer


  6. Posts : 5
    win 7 64-bit
    Thread Starter
       #16

    What is the end goal of this mouse movement? To prevent screensaver or power settings from kicking in?
    Actually, it is to prevent having to reauthenticate. I understand the difference in what you point out,but not sure how (or if) either of them relate to logging in. I need to do some digging to better understand that.

    -John
      My Computer


  7. Posts : 10,485
    W7 Pro SP1 64bit
       #17

    If this mouse movement is to keep a VPN alive, then ping might be enough/better.

    As far as moving the mouse - a scripting language like AutoHotKey or AutoIt will do. The AutoIt code in the attached text file (mm1.txt) does what you asked - but exiting that script is a bit problematic. The AutoIt code in (mm2.txt) is less likely to get a gamer banned while AFK.

    See this post for some warnings/options about using AutoIt.
    undesirable .bat file side effects in Win7 pro 64-bit Attached Files
      My Computer


  8. Posts : 1
    Windows 7Ultimate x64
       #18

    Or you might just try removing:
    @echo off

    from the batch file.

    Was told long ago when modems were used (tin-cans and strings like) in BBS
    type batch files, @echo off removed the seen text on screen to stop some one
    from seeing and Cntl-C ing the batch file.
    My 2 cents FWIW..
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:10.
Find Us