CrescendoBEAt Posted May 31, 2005 Posted May 31, 2005 hello everyone, i know zip about programming but i need to do 1 task which i think that would be done by programming in VB or VBS.i want to put one CMD command in a simple Script maybe, which every time that i double click on it, just that CMD command run. i think that would be and interface or simple script to tell to CMD to run this command.anyone can help in this matter?!THANX a lot B)
Martin Zugec Posted May 31, 2005 Posted May 31, 2005 Ehm, sorry, try to describe what exactly you want to do...
CrescendoBEAt Posted June 1, 2005 Author Posted June 1, 2005 hiwhat should i explain? i mean i need just a simple script that contain a simple CMD command which everytime i click on that script, the command run and then close the windows, and i get the result in output file.
CrescendoBEAt Posted June 1, 2005 Author Posted June 1, 2005 hiwhat should i explain? i mean i need just a simple script that contain a simple CMD command which everytime i click on that script, the command run and then close the windows, and i get the result in output file.
Martin Zugec Posted June 1, 2005 Posted June 1, 2005 Why not running that cmd (you mean console command?) directly?
gunsmokingman Posted June 2, 2005 Posted June 2, 2005 Try This It A Simple Directory Cmd Save it as Dir.vbs Hope this is what you wanted.Dim Act : Set Act = CreateObject("Wscript.Shell")Sd = Act.ExpandEnvironmentStrings("%systemdrive%")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Cmd = ("%comspec% /T:9a /c TITLE Check For Folder | cls && Mode 75,25 && Color 9e && dir >>"& SD & "\Temp.txt")Act.Run(Cmd), 1, True Set WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "Here Is The Cmd Script" WF.WriteLine Cmd WF.Close Act.run(Sd & "\Temp.txt") wscript.sleep 3000 Fso.DeleteFile(Sd & "\Temp.txt")
CrescendoBEAt Posted June 4, 2005 Author Posted June 4, 2005 hi gunsmokingman, thanks for that,but how can i change it to other commands? and what this really codes is?
gunsmokingman Posted June 4, 2005 Posted June 4, 2005 Here I will try and break it down what this code does1:\ This is a Visual Basic Script or VBS for short2:\ It is saying I am going to start a Command Promt and outputthe script to a text fileCmd = ("%comspec% /T:9a /c TITLE Check For Folder | cls && Mode 75,25 && Color 9e && dir >>"& SD & "\Temp.txt")3:\It then start the Command Promt with this lineAct.Run(Cmd), 1, True4:\ Then after the Command Promt Has Completed Then I have ItUse VBS The Set Is to shorten Down This CreateObject("Scripting.FileSystemObject") Set Fso = CreateObject("Scripting.FileSystemObject") To Just Fso.OpenTextFileWhich Uses This Class to open the text file made in the Command Promt and add the extra lines of text.5:\ The script then uses the built in sleep function to rest for 3 secondswscript.sleep 30006:\ It then uses the CreateObject("Scripting.FileSystemObject") to delet the file.Orange Is The New Name For The Action Part Of the Command Promt The Advantage of this is it saves a lot of typing. You can use any of Command Promt Built In Functions In this Script.Just Change This dir to any of it functionstry Ver Dim Act : Set Act = CreateObject("Wscript.Shell")Sd = Act.ExpandEnvironmentStrings("%systemdrive%")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Cmd = ("%comspec% /T:9a /c TITLE Check For Folder | cls && Mode 75,25 && Color 9e && dir >>"& SD & "\Temp.txt")Act.Run(Cmd), 1, TrueSet WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "Here Is The Cmd Script" WF.WriteLine Cmd WF.Close Act.run(Sd & "\Temp.txt") wscript.sleep 3000 Fso.DeleteFile(Sd & "\Temp.txt")This One I Have Added 3 More Command Promt Functions To It.Save This As Cmd.vbsDim Act : Set Act = CreateObject("Wscript.Shell")Sd = Act.ExpandEnvironmentStrings("%systemdrive%")Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Cmd = ("%comspec% /T:9a /c TITLE Check For Folder | cls && Mode 75,25 && Color 9e && Dir >>"& SD & "\Temp.txt")Act.Run(Cmd), 1, True Set WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "Here Is The Dir Script" WF.WriteLine Cmd WF.WriteLine "Next" WF.CloseCmd = ("%comspec% /T:9a /c TITLE Check The Windows Version | cls && Mode 75,25 && Color 9e && Ver >> " & SD & "\Temp.txt")Act.Run(Cmd), 1, True Set WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "The Windows Version" WF.WriteLine Cmd WF.WriteLine "Next" WF.CloseCmd = ("%comspec% /T:9a /c TITLE Check The Time | cls && Mode 75,25 && Color 9e && Time /t >>" & SD & "\Temp.txt")Act.Run(Cmd), 1, True Set WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "The Time Of The Script" WF.WriteLine Cmd WF.WriteLine "Next" WF.CloseCmd = ("%comspec% /T:9a /c TITLE Check The Date | cls && Mode 75,25 && Color 9e && Date /t >>" & SD & "\Temp.txt")Act.Run(Cmd), 1, True Set WF = Fso.OpenTextFile( Sd & "\Temp.txt", 8,true) WF.WriteLine "The Date Of The Script" WF.WriteLine Cmd WF.WriteLine "Next" WF.Close Act.run(Sd & "\Temp.txt") wscript.sleep 3000 Fso.DeleteFile(Sd & "\Temp.txt")Hope This Helps
CrescendoBEAt Posted June 9, 2005 Author Posted June 9, 2005 thanks a lot Gunsmokingmani test it and this is exactly what i wanted!!!thanks a lotand other guys
CrescendoBEAt Posted June 9, 2005 Author Posted June 9, 2005 by the way how can i learn to write VBScript for myself? i mean it's easy or not? cuz i recently finished my MCSE and i like to write script for network as needed.thanks for ur advice
gunsmokingman Posted June 9, 2005 Posted June 9, 2005 I am a self taught on VBS no courses or nothing,Here is the spot I go to learn about VBS scripting.I am glad I could help on this.Hey, Scripting Guy!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now