Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


gunsmokingman

Super Moderator
  • Content Count

    2,291
  • Donations

    $0.00 
  • Joined

  • Last visited

Community Reputation

22 Excellent

About gunsmokingman

  • Birthday 09/26/1962

Profile Information

  • OS
    none specified
  • Country

Flags

  • Country Flag

Recent Profile Visitors

3,366 profile views
  1. This simple script is the VBS way of renaming a file using Drag And Drop and changing the file name to one with using HourMinuteSecond.FileExtension for it new name '-> Object To Copy And Delete File Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Run Time Varibles Dim FName, Nname '-> Check For Drag And Drop And Then Process A Single File If WScript.Arguments.Count = 1 Then '-> Get File So You Can Get It Path Set FName = Fso.GetFile(WScript.Arguments(0)) '-> File New Name Using HourMinutesSecomds.FileExtension Nname = Hour(Now) & Minute(Now) & Second(Now) & "." & Right(FName.Path,3) '-> Copy Drag And Drop File To It New Name FName.Copy(Replace(FName.Path,FName.Name,Nname)),True '-> Delete The Original Faile Fso.DeleteFile WScript.Arguments(0),True Else '-> For No File Or To Many File Error If WScript.Arguments.Count = 0 Then WScript.Echo _ "Drag and Drop One File On To This Script To Have It Function" If WScript.Arguments.Count > 1 Then WScript.Echo _ "To Many Files, This Script Can Process Only 1 File at a Time" End If
  2. Here a demo menu cmd I made to turn on or @Echo Off CLS COLOR 9F MODE 62,9 TITLE Demo Menu :Main CLS Echo. Echo This Is To Turn On Or Turn Off The Hiberfil.sys Echo. Echo Type YES For This Choice Echo Type NO For This Choice Echo Type Quit To Close Window Echo. SET Choice= SET /P Choice=Type Choice Then Press Enter: IF /I '%Choice%'=='yes' GOTO Item1 IF /I '%Choice%'=='no' GOTO Item2 IF /I '%Choice%'=='quit' GOTO TheEnd ECHO "%Choice%" is not valid. Please try again. SET /P = Press Enter To Continue GOTO MAIN :Item1 CLS Echo. Echo You Selected Choice 1 ping -n 3 127.0.0.1>nul Goto TheEnd :Item2 CLS Echo. Echo You Selected Choice 2 ping -n 3 127.0.0.1>nul Goto TheEnd :TheEnd Exit
  3. Cmd promt Echo www.google.com and open google.com Echo Off CLS Color 9F Mode 75, 17 Echo Opening www.google.com ping -n 2 127.0.0.1>nul start www.google.com ping -n 3 127.0.0.1>nul
  4. If you can use VBS here is a VBS script that checks all local active drives searching for a file called Test.txt. '-> Objects For Run Time Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles For Run Time Dim Chk, Drv, Fil, Tmp '-> File Name To Search For Fil = "\Test.txt" '-> Check File Set To False If Found It Becomes True Chk = False '-> Loop For All The Drives For Each Drv In Fso.Drives '-> If Drive is Active If Drv.IsReady = True Then '-> Check For The File On A Active Drive If Fso.FileExists(Drv & Fil) Then '-> If Check File Found Do Some Action WScript.Echo Drv & Fil Chk = True Else '-> Colllect The Drives That Are Missing The Check File Tmp = Tmp & "Missing : " & Drv & Fil & vbCrLf End If End If Next '-> If The Check File Is Missing If Chk = False Then WScript.Echo Tmp End If
  5. Why not use VBS to do what you want. This way you do not have 3rd party apps to do what you want. If MsgBox("Would you like to restart the Computer?",4132,_ "Shut Off Computer") = 6 Then '-> Code Below Here Yes MsgBox "User said yes to restart" Else '-> Code Below Here No MsgBox "User said no to restart" End If
  6. To recap jaclaz all you have offer is nothing other than some apps that OP did not want to use. 1:\ The only way you might be able to do this is with VBS sendkeys method https://social.technet.microsoft.com/wiki/contents/articles/5169.vbscript-sendkeys-method.aspx This means, it might work or it might not work No where does it say it will work or that this is the only way of doing it. 2:\ I have given the OP a solution to his problem that he elected not to use
  7. You are wrong jaclaz Sendkeys does work on cmd.exe, I was able to send text and have it do a DIr command and exit.
  8. I did a test of cmd.exe using Sendkeys I did manage to get something to work. The problem is the loop for cmd.exe it just stays stuck in the loop. Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Act.Run("cmd.exe"),1,False Success = Act.AppActivate("cmd.exe") Wscript.Sleep 1000 Act.SendKeys "COLOR 9F" :WScript.Sleep 100 Act.SendKeys "{ENTER}" :WScript.Sleep 500 WScript.Sleep 100 Act.SendKeys "Test of AppActivate." :WScript.Sleep 1000 Act.SendKeys "{ENTER}" Act.SendKeys "CLS" :WScript.Sleep 100 Act.SendKeys "{ENTER}" Act.SendKeys "Dir /B" :WScript.Sleep 500 Act.SendKeys "" :WScript.Sleep 500 Act.SendKeys "{ENTER}" Act.SendKeys "Exit" :WScript.Sleep 3500 Act.SendKeys "{ENTER}" [/CODE]
  9. The SendKey method is not a very reliable way of doing things. The best way I think to do what Mike86 wants is use CreateObject("Wscript.Shell").run method and use it own built in method of displaying how the app windows appear. Table 3.9 Integers Accepted by the Run Method for the Window Style https://technet.microsoft.com/en-us/library/ee156605.aspx Integer = Window Style Description 0 = Hides the window and activates another window. 1 = Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. 2 = Activates the window and displays it as a minimized window. 3 = Activates the window and displays it as a maximized window. 4 = Displays a window in its most recent size and position. The active window remains active. 5 = Activates the window and displays it in its current size and position. 6 = Minimizes the specified window and activates the next top-level window in the Z order. The Z order is nothing more than the list detailing the order in which windows are to be activated. If you press ALT+TAB, you will see a graphical representation of the Z list. 7 = Displays the window as a minimized window. The active window remains active. 8 = Displays the window in its current state. The active window remains active. 9 = Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. 10 = Sets the show-state based on the state of the program that started the application.
  10. Here is a SendKey Demo in VBS [CODE} Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Act.Run("Notepad.exe"),1,False Do Until Success = True Success = Act.AppActivate("Notepad") Wscript.Sleep 1000 Loop '-> Send keys Body Message Act.SendKeys "This is a test of AppActivate." WScript.Sleep 1000 Act.SendKeys "{ENTER}" Act.SendKeys "T" :WScript.Sleep 500 Act.SendKeys "e" :WScript.Sleep 500 Act.SendKeys "s" :WScript.Sleep 500 Act.SendKeys "t" :WScript.Sleep 500 '-> Send keys For saving File Act.SendKeys "%F" Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{ENTER}" :WScript.Sleep 500 '-> Send key Save Text File Name Act.SendKeys "T" :WScript.Sleep 500 Act.SendKeys "e" :WScript.Sleep 500 Act.SendKeys "m" :WScript.Sleep 500 Act.SendKeys "p" :WScript.Sleep 500 Act.SendKeys ".txt":WScript.Sleep 500 Act.SendKeys "{ENTER}",500 '-> Send File Keys To Close Act.SendKeys "%F" :WScript.Sleep 1000 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{ENTER}" :WScript.Sleep 500 '_> Remove The Created Text File Dim F, P P = Act.ExpandEnvironmentStrings("%Userprofile%") & "\Documents\Temp.txt" Set F = Fso.GetFile(P) F.Delete [/CODE} Rename Demo_SendKey.vbs.txt to Demo_SendKey.vbs to make active Demo_SendKey.vbs.txt
  11. Mike88 if you want a simple way to do what you want could you run the cmd from vbs Example [CODE} Dim Act :Set Act = CreateObject("Wscript.Shell") '-> First Cmd Show Windows Wait Until Finished Act.Run("Some1.cmd /Switches"),1,True '-> Second Cmd Hide Windows Wait Until Finished Act.Run("Some2.cmd /Switches"),0,True '-> Third Cmd Show Windows Wait Until Finished Act.Run("Some3.cmd /Switches"),1,True {/CODE] Table 3.9 Integers Accepted by the Run Method for the Window Style https://technet.microsoft.com/en-us/library/ee156605.aspx
  12. The only way you might be able to do this is with VBS sendkeys method https://social.technet.microsoft.com/wiki/contents/articles/5169.vbscript-sendkeys-method.aspx
  13. Start with a Google query like Code language for drivers https://www.google.ca/search?q=Code+langauge+for+Drivers&rlz=1C1CHBD_en-GBCA757CA757&oq=Code+langauge+for+Drivers&aqs=chrome..69i57.10342j0j8&sourceid=chrome&ie=UTF-8
  14. I am not sure what you want but using this reference https://msdn.microsoft.com/en-us/library/windows/desktop/aa378858(v=vs.85).aspx I put together this script run it and see if it what you need. Dim d,oWMI, oSR, colItem, objItem Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set oSR = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore") Set colItem = oWMI.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3") On Error Resume Next For Each objItem In colItem d = objItem.Name & "\" If (oSR.Enable(d)) = 0 Then wscript.Echo "Success" & vbTab & d Else wscript.Echo "Failed " & vbTab & d End If Next
  15. I have updated the original script 1:\ Added a message box to appear with instructions on how to use 2:\ Added a new user input to search for the file type New Code Dim Col,Str, Res :Str = "." Dim Wmi :Set Wmi = GetObject("winmgmts:\\" & Str & "\root\cimv2") '-> Check To Nake Sure Cscript Is Used If InStr(1,WScript.FullName,"cscript",1) Then UserImput() '-> Main Search Object Using The User Input Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where Extension = '" & Res &"'") WScript.StdOut.WriteLine "Begin Querry For " & Res Main() Else '-> Wrong Script Engine MsgBox Space(10) & "Error Wrong Scripting Engine" & vbCrLf & _ "You must right click this script and select the Cmd Prompt or" & vbCrLf & _ "Csript option to run this script",4128,"Error Wrong Script Engine" End If '-> Main Function To Collect All The Files Function Main() If Col.count = 0 Then WScript.StdOut.WriteLine "Can Not Find This File Type" WScript.Sleep 3500 WScript.Quit Else WScript.StdOut.WriteLine "Processing Please Wait..." For Each Obj in Col '-> Display File Type WScript.StdOut.WriteLine Obj.Name WScript.Sleep 300 Next End If Res = "" CloseCmd() End Function '-> Get User Input For File Type Function UserImput() Do While Res = "" WScript.StdOut.WriteBlankLines 1 WScript.StdOut.WriteLine _ "Type the file type you are searching for in this" & vbCrLf &_ "format txt or vbs or cmd no dot is needed." & vbCrLf & _ "Type exit or quit to stop the script." WScript.StdOut.WriteBlankLines 1 Res = Wscript.StdIn.ReadLine Select Case LCase(Res) Case "exit" WScript.Quit Case "quit" WScript.Quit End Select Loop End Function '-> Close The CMD Window Function CloseCmd() Do While Res = "" WScript.StdOut.WriteBlankLines 2 WScript.StdOut.WriteLine "Total File Count : " & Col.count WScript.StdOut.WriteLine "Type quit Or exit to close CMD window" Res = Wscript.StdIn.ReadLine Select Case LCase(Res) Case "exit" WScript.Quit Case "quit" WScript.Quit End Select Loop End Function Rename WmiUserInExtSearch.vbs.txt to WmiUserInExtSearch.vbs to make active WmiUserInExtSearch.vbs.txt
×
×
  • Create New...