write to vbs file ...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • GoOgLe
    Forum Member
    • Mar 2007
    • 452

    write to vbs file ...

    how can i write it to vbs file and then run it ???

    Code:
    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
    Set colNetCards = objWMIService.ExecQuery _
        ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    
    For Each objNetCard in colNetCards
        arrDNSServers = Array("0.0.0.0", "0.0.0.0")
        objNetCard.SetDNSServerSearchOrder(arrDNSServers)
    Next
  • GoOgLe
    Forum Member
    • Mar 2007
    • 452

    #2
    what 's wrong with that code ? i cant replace this1 !!!

    Code:
    contents = TextFile.ReadToString("AutoPlay\\Docs\\1.vbs");
    error = Application.GetLastError();
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
        result = Dialog.Input("This1", "Your answer:", "", MB_ICONQUESTION);
        new_contents = String.Replace(contents, "this1", result, true);
        TextFile.WriteFromString("AutoPlay\\Docs\\1.vbs", new_contents, false);
         result2 = Dialog.Input("This2", "Your answer:", "", MB_ICONQUESTION);
        new_contents2 = String.Replace(contents, "this2", result2, true);
         TextFile.WriteFromString("AutoPlay\\Docs\\1.vbs", new_contents2, false);
          
        error = Application.GetLastError();
              if (error ~= 0) then
            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
            else
            Application.Sleep(1000);
    		Shell.Execute("AutoPlay\\Docs\\1.vbs", "open", "", "", SW_SHOWNORMAL);
    
        end
        
    end
    Last edited by GoOgLe; 04-18-2008, 01:01 AM.

    Comment

    • ShadowUK
      No longer a forum member
      • Oct 2007
      • 1322

      #3
      Code:
      TextFile.WriteFromString(_TempFolder.."\\file.vbs", "strComputer = \".\"\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\" _\r\n    & \"{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\n\r\nSet colNetCards = objWMIService.ExecQuery _\r\n    (\"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True\")\r\n\r\nFor Each objNetCard in colNetCards\r\n    arrDNSServers = Array(\"0.0.0.0\", \"0.0.0.0\")\r\n    objNetCard.SetDNSServerSearchOrder(arrDNSServers)\r\nNext", false);
      Shell.Execute(_TempFolder.."\\file.vbs", "open", "", "", SW_SHOWNORMAL);

      Comment

      • GoOgLe
        Forum Member
        • Mar 2007
        • 452

        #4
        thanks alot ShadowUK :yes

        how can i change this 2 data with 2 dialog inputs ?
        Array(\"0.0.0.0\", \"0.0.0.0\")

        Comment

        • ShadowUK
          No longer a forum member
          • Oct 2007
          • 1322

          #5
          Originally posted by GoOgLe View Post
          thanks alot ShadowUK :yes

          how can i change this 2 data with 2 dialog inputs ?
          Array(\"0.0.0.0\", \"0.0.0.0\")
          Code:
          input1 = Dialog.Input("", "");
          input2 = Dialog.Input("", "");
          
          if (input1 and input2) then
            Array("\""..input1.."\", \""..input2.."\"")
          end

          Comment

          • GoOgLe
            Forum Member
            • Mar 2007
            • 452

            #6
            thanks alot shadowUK

            Code:
            input1 = Dialog.Input("", "");
            input2 = Dialog.Input("", "");
            if (input1 and input2) then
            TextFile.WriteFromString(_TempFolder.."\\here4.vbs", "strComputer = \".\"\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\" _\r\n    & \"{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\n\r\nSet colNetCards = objWMIService.ExecQuery _\r\n    (\"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True\")\r\n\r\nFor Each objNetCard in colNetCards\r\n    arrDNSServers = Array(\""..input1.."\", \""..input2.."\")\r\n    objNetCard.SetDNSServerSearchOrder(arrDNSServers)\r\nNext", false);
            Shell.Execute(_TempFolder.."\\here4.vbs", "open", "", "", SW_SHOWNORMAL);
            end

            is it possible to make inputs with dots "." ?
            Last edited by GoOgLe; 04-18-2008, 01:24 AM.

            Comment

            • GoOgLe
              Forum Member
              • Mar 2007
              • 452

              #7
              i found it...

              Dialog.MaskedInput

              Comment

              • GoOgLe
                Forum Member
                • Mar 2007
                • 452

                #8


                i want it cancel if dialog is null (if user types nothing to any of the dialogs, it will cancel)

                Code:
                input1 = Dialog.MaskedInput("", "", "###.###.###.###", "", MB_ICONQUESTION, " ");
                input2 = Dialog.MaskedInput("", "", "###.###.###.###", "", MB_ICONQUESTION, " ");
                if (input1 and input2 ~= nil) then
                TextFile.WriteFromString(_TempFolder.."\\file.vbs", "strComputer = \".\"\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\" _\r\n    & \"{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\n\r\nSet colNetCards = objWMIService.ExecQuery _\r\n    (\"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True\")\r\n\r\nFor Each objNetCard in colNetCards\r\n    arrDNSServers = Array(\""..input1.."\", \""..input2.."\")\r\n    objNetCard.SetDNSServerSearchOrder(arrDNSServers)\r\nNext", false);
                Shell.Execute(_TempFolder.."\\file.vbs", "open", "", "", SW_SHOWNORMAL);
                end
                Last edited by GoOgLe; 04-18-2008, 01:42 AM.

                Comment

                • GoOgLe
                  Forum Member
                  • Mar 2007
                  • 452

                  #9
                  i want to do it with RizlaUK's AMSPrettyDialog.dll... what am i doing wrong ?
                  Code:
                  Title = "Set" 
                  TextA = "1" 
                  TextB = "2"
                  DefA = ""
                  DefB = ""
                  ButtonA = "Yes" 
                  ButtonB = "No" 
                  Border = 0 
                  
                  App = Application.GetWndHandle(); 
                  
                  Args = "\""..Title.."\",\""..TextA.."\",\""..TextB.."\",\""..DefA.."\",\""..DefB.."\",\""..ButtonA.."\",\""..ButtonB.."\","..Border..","..App
                  
                  result = DLL.CallFunction("AutoPlay\\Docs\\DLLPerttyDailogs.dll", "ShowPrettyDaulInput", Args, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
                  
                  if result ~= "0" and result ~= "" then
                  	tbResults = DelimitedStringToTable(result,"|");
                  	TextFile.WriteFromString(_TempFolder.."\\file.vbs", "strComputer = \".\"\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\" _\r\n    & \"{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\n\r\nSet colNetCards = objWMIService.ExecQuery _\r\n    (\"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True\")\r\n\r\nFor Each objNetCard in colNetCards\r\n    arrDNSServers = Array(\"tbResults[1].."\r\n"..tbResults[2]\")\r\n    objNetCard.SetDNSServerSearchOrder(arrDNSServers)\r\nNext", false);
                  Shell.Execute(_TempFolder.."\\file.vbs", "open", "", "", SW_SHOWNORMAL);
                  else
                  
                  end

                  Comment

                  • ShadowUK
                    No longer a forum member
                    • Oct 2007
                    • 1322

                    #10
                    You've asked 3 questions, if you read the scripting guide I'm sure you would find out exactly what you are looking for..

                    Comment

                    • GoOgLe
                      Forum Member
                      • Mar 2007
                      • 452

                      #11
                      i am stuck here...

                      i tried:
                      Code:
                      arrDNSServers = Array(\"tbResults[1].."\r\n"..tbResults[2]\")\r\n
                      i tried:
                      arrDNSServers = Array("\tbResults[1].."\r\n"..tbResults[2]"\)\r\n
                      i tried:
                      arrDNSServers = Array(\tbResults[1].."\r\n"..tbResults[2]\)\r\n
                      i tried:
                      arrDNSServers = Array("tbResults[1].."\r\n"..tbResults[2]")\r\n
                      none worked !!!
                      Last edited by GoOgLe; 04-18-2008, 04:05 AM.

                      Comment

                      • GoOgLe
                        Forum Member
                        • Mar 2007
                        • 452

                        #12
                        works but doesnt effect !!!

                        Code:
                        arrDNSServers = Array(\""..DefA.."\", \""..DefB.."\")\r\n

                        Comment

                        • GoOgLe
                          Forum Member
                          • Mar 2007
                          • 452

                          #13
                          just turn back to normal one... how can i make it not to show input2 if input1 cancelled or no text entered ?

                          Code:
                          input1 = Dialog.Input("1", "");
                          input2 = Dialog.Input("2", "");
                          if (input1 or input2 == "CANCEL") then else
                          TextFile.WriteFromString(_TempFolder.."\\here4.vbs", "strComputer = \".\"\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\" _\r\n    & \"{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")\r\n\r\nSet colNetCards = objWMIService.ExecQuery _\r\n    (\"Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True\")\r\n\r\nFor Each objNetCard in colNetCards\r\n    arrDNSServers = Array(\""..input1.."\", \""..input2.."\")\r\n    objNetCard.SetDNSServerSearchOrder(arrDNSServers)\r\nNext", false);
                          Shell.Execute(_TempFolder.."\\here4.vbs", "open", "", "", SW_SHOWNORMAL);
                          end

                          Comment

                          Working...
                          X