Content Type
Profiles
Forums
Events
Everything posted by gunsmokingman
-
Find the recycle bin
gunsmokingman replied to Glenn9999's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
jaclaz my script did not pick up these 3 folders name in a test I did. Test Folders Name Partial Scan Results From the list above it did not list those 3 folders for the test. Using WMI Code Creator And Results Not Showing The Test Folders Coffee it sound the method you posted uses the same brute force as a VBS script. -
Find the recycle bin
gunsmokingman replied to Glenn9999's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Ok the script looks for recy in it path Example Wmi Path and what it filtering strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_Directory",,48) For Each objItem in colItems If Instr(1,objItem.Path,"recy",1) Then Wscript.Echo "-----------------------------------" Wscript.Echo "Path: " & objItem.Path end If Next What It Filter Out When used with caption return the path to the folder If there where any names in the path they would get listed -
Find the recycle bin
gunsmokingman replied to Glenn9999's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I guess that was not clear enough for you to readThe Script ment to list Folder recy in it path case insensitive. Some Of The Results -
Find the recycle bin
gunsmokingman replied to Glenn9999's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I do not know if this will help but here is a VBS script that should list all Various Recycle Bin on the local computer. Save As Find_RecyleBin.vbs '-> Objects For Runtime Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") '-> Varibles For Runtime Dim D1, Ln, Obj, Ts, Txt, T1, T2, T3 Ln = "-----------------------------------" '-> Path To User Desktop And Text Report Txt = Act.SpecialFolders("Desktop") & "\RecyleBinRpt.txt" '-> Create Text File To Log Results Set Ts = Fso.CreateTextFile(Txt) '-> Date Time Varibles D1 = Day(Date) T1 = Hour(Time) T2 = Minute(Time) T3 = Second(Time) '-> Adds Zero To Number EG 1 Would Become 01 If Len(D1) = 1 Then D1 = "0" & D1 If Len(T1) = 1 Then T1 = "0" & T1 If Len(T2) = 1 Then T2 = "0" & T2 If Len(T3) = 1 Then T3 = "0" & T3 '-> Write Date Time To Text File Ts.WriteLine "Scan Date : " & MonthName(Month(Now),False) & "/" & _ WeekdayName(Weekday(Now),False) & "," & D1 & "/" & Year(Now) Ts.WriteLine "Scan Time : " & T1 & ":" & T2 & ":" & T3 & vbCrLf & Ln '-> Loop Threw All Folders And Sub Folder On Local Computer For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_Directory") '-> Filter Out Various Recycle Bin Paths If Instr(1,Obj.Path,"recy",1) Then Ts.WriteLine Obj.Caption & vbCrLf & Ln End If Next '-> Close Text File Ts.Close '-> Read The Text File Chr(34) = " Act.Run(Chr(34) & Txt & Chr(34)),1,True '-> After Closing Text Files Msgbox Ask To Keep Or Delete If MsgBox("Would You Like To Keep This File?" & vbCrLf & _ "Yes To Keep File, No To Delete File" & vbCrLf & _ Txt,4132,"Keep Or Delete") = 7 Then Fso.DeleteFile(Txt) End If Rename Find_RecyleBin.vbs.txt to Find_RecyleBin.vbs to make active. Find_RecyleBin.vbs.txt -
Could you not use a HTA with VBS scripting or JS scripting Example with Username and Masked Textbox HTA Demo_Password.hta <!-- Created By Gunsmokingman Aka Jake1Eye 4:33 PM November-28-11 --> <TITLE>Demo Password</TITLE> <HTA:APPLICATION ID="Demo Password" APPLICATIONNAME="GsmDemoPW" Border="Thin" BORDERSTYLE ="Complex" Caption="Yes" INNERBORDER ="No" MaximizeButton="No" MinimizeButton="No" Scroll="No" SCROLLFLAT ="No" ShowInTaskBar='No' SingleInstance="Yes" SysMenu="No" WindowState="Normal"/> <STYLE Type='text/css'> Body { Font-Size:9.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:Black; BackGround-Color:Transparent; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#ece6e0',EndColorStr='#c0bab4'); Margin-Top:21; Margin-Bottom:1; Margin-Left:4; Margin-Right:4; Padding-Top:1; Padding-Bottom:1; Padding-Left:4; Padding-Right:4; Text-Align:Center; Vertical-Align:Top; Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; } BUTTON { Cursor:Hand; Height:19; Width:69; Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:#001141; Text-Align:Center; Vertical-Align:Middle; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='AliceBlue',endColorStr='LightSlateGray'); Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; Padding-Top:0; Padding-Bottom:0; Padding-Left:0; Padding-Right:0; Margin-Top:2; Margin-Bottom:0; Margin-Left:1; Margin-Right:1; BackGround-Color:Transparent; } INPUT { Height:17; Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; } </STYLE> <script Language='VBScript'> '-> Resize And Move Window Dim Wth :Wth = int(325) Dim Hht :Hht = int(175) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2)) '-> Function To Process Submit Button Function PwChk() If Len(Pswd.value) >= 4 And Len(UsNm.value) >= 4 Then alert(UsNm.value & vbcrlf & Pswd.value) ElseIf Len(Pswd.value) =< 3 And Len(UsNm.value) >= 4 Then alert("Password Must Be At Least 4 Characters" & vbcrlf & _ Len(Pswd.value) & vbcrlf & _ "User Name Is 4 Characters Or Better" & vbcrlf & _ Len(UsNm.value)) Pswd.value = "" ElseIf Len(Pswd.value) >= 4 And Len(UsNm.value) =< 3 Then alert("Password Is 4 Characters Or Better" & vbcrlf & _ Len(Pswd.value) & vbcrlf & _ "User Name Must Be At Least 4 Characters" & vbcrlf & _ Len(UsNm.value)) UsNm.value = "" ElseIf Len(Pswd.value) = 0 And Len(UsNm.value) = 0 Then alert("No Values In The Textboxes") End If End Function </Script> <BODY> <!-- UserName --> <DIV>Please Type In Your Username?<BR> <INPUT Type='Text' Name='UsNm' MaxLength='28' Size='30'/> </DIV> <!-- Password --> <DIV>Please Type In Your Password?<BR> <INPUT Type='password' Name='Pswd' MaxLength='12' Size='30'/> </DIV> <!-- Buttons --> <DIV> <BUTTON ID='B01' OnClick='PwChk()'>Submit</BUTTON> <BUTTON ID='B02' OnClick='UsNm.value = "":Pswd.value = ""'>Clear</BUTTON> <BUTTON ID='B03' OnClick='window.Close()'>Close</BUTTON> </DIV> </BODY> Demo_Password.zip
-
There really no need to use third party apps to create shortcuts. VBS scripting has a method to create short cuts. Could you post your batch scripts that you use, we might be able to convert those to VBS, so you would have only one script to work with. How to create a desktop shortcut with the Windows Script Host
-
Here is what I understand, could be wrong 1:\ He has uncompressed updates in one folder 2:\ He has compressed updates in another 3:\ He want to extract compressed ones then install all Here is a VBS script only tested to run without errors without testing these Install Updates or Extract Updates Item In The Script You Need To Change Or Check Save As ExtInstallKb.vbs this script will run and Produce a text file without changes ''-> Object For Run Time Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles Used At Run Time Dim c34 :c34 = Chr(34) Dim Zip :Zip = Act.CurrentDirectory & "\Tools\" Dim Ext :Ext = Act.ExpandEnvironmentStrings("%tmp%\KbInstall") Dim Rpt :Rpt = Act.ExpandEnvironmentStrings("%tmp%\KbInstall\KbRpt.txt") '-> Varibles For Loop And Text Stream Dim Col, Chk, Obj, Ts '-> Create Temp Folder If Not Fso.FolderExists(Ext) Then Fso.CreateFolder(Ext) '-> Open Text Report Set Ts = Fso.CreateTextFile(Rpt) Ts.WriteLine " Script Date : " & Year(Now) & "-" & _ MonthName(Month(Now),False) & "-" & _ WeekdayName(Weekday(Now),False) & "," & Day(Date) Ts.WriteLine " Script Time : " & Hour(Time) & ":" & _ Minute(Time) & ":" & Second(Time) & vbCrLf '-> Recursive(Fso.GetFolder(".")) ' Uses Script Location As Parent Folder To Start Recursive Search ' Of All Folders And There Sub Folders Recursive(Fso.GetFolder(".")) If Chk = True Then Ts.WriteLine vbCrLf & " Installing Updates In : " & Fso.GetFolder(Ext).Path '-> Loop Threw Updates In Temp Folder For Each Obj In Fso.GetFolder(Ext).Files If Right(InStr(1,Obj.Name,"msu",1),3) Or _ Right(InStr(1,Obj.Name,"ms1",1),3) Or _ Right(InStr(1,Obj.Name,"exe",1),3) Then Ts.WriteLine " Install Update : " & Obj.Path '-> Remove Only For Demo Show KB Unstall Command Ts.WriteLine "Act.Run(" & c34 & Obj & c34 & " /quiet /norestart" & "),1,True" '-> UnComment To Make Active ' Act.Run(c34 & Obj & c34 & " /quiet /norestart"),1,True End If Next Else Ts.WriteLine vbCrLf & " Nothing was extracted or installed." End If '-> Close The Report Ts.Close() '-> Open The Report To Read Act.Run(c34 & Rpt & c34),1,True '-> Ask To Keep Or Delete Report If MsgBox("Would You Like To Keep This Report",4132, _ "Keep Or Delete") = 6 Then Fso.CopyFile Rpt, Act.SpecialFolders("Desktop") & "\KbRpt.txt",True End If '-> Delete The Temp Folder If Fso.FolderExists(Ext) Then Fso.DeleteFolder(Ext) '-> List All Folders And Files Function Recursive(Folder) Ts.WriteLine vbCrLf & " Searching Folder: " & Folder For Each Obj In Folder.Files '-> Filter Out Script From Being Process If Not InStr(1,Obj.Path,WScript.ScriptFullName,1) Then '-> Filter Out Updates By Name If InStr(1,Obj.Name,"kb7",1) Or InStr(1,Obj.Name,"kb8",1) Or _ InStr(1,Obj.Name,"kb9",1) Then If Right(InStr(1,Obj.Name,"msu",1),3) Then Chk = True Ts.WriteLine " Confirm Update : " & Obj.Name Fso.CopyFile Obj, Ext & "\", True ElseIf Right(InStr(1,Obj.Name,"zip",1),3) Then Ts.WriteLine " Confirm Zip KB : " & Obj Chk = True '-> Remove Only For Demo Show 7z File For Extract To Where It Extracted To Ts.WriteLine "Act.Run(" & Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & c34 & Ext & c34 & " -y),1,true" '-> UnComment To Make Active ' Act.Run(Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & Ext & " -y") End If End If End If Next 'Ts.WriteLine For Each Col In Folder.SubFolders Recursive(Col) Next End Function Rename ExtInstallKb.vbs.txt from to ExtInstallKb.vbs to make active script. This will run and Produce a text file without changes or errors ExtInstallKb.vbs.txt
-
Batch script for imagex error
gunsmokingman replied to yweiss's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here try this HTA if you want a GUI to work with. <!-- Created By Gunsmokingman Aka Jake1Eye 1:15 PM November-09-11 --> <TITLE>ImageX Gui</TITLE> <HTA:APPLICATION ID="ImageX Gui" APPLICATIONNAME="ImageXGui" Border="Thin" BORDERSTYLE ="Complex" Caption="Yes" INNERBORDER ="No" MaximizeButton="No" MinimizeButton="No" Scroll="No" SCROLLFLAT ="No" SingleInstance="Yes" SysMenu="No" WindowState="Normal"/> <STYLE Type='text/css'> Body { Font-Size:9.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:Black; BackGround-Color:Transparent; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#ece6e0',EndColorStr='#c0bab4'); Margin-Top:21; Margin-Bottom:1; Margin-Left:4; Margin-Right:4; Padding-Top:1; Padding-Bottom:1; Padding-Left:4; Padding-Right:4; Text-Align:Center; Vertical-Align:Top; Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; } BUTTON { Cursor:Hand; Height:19; Width:69; Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:#001141; Text-Align:Center; Vertical-Align:Middle; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='AliceBlue',endColorStr='LightSlateGray'); Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; Padding-Top:0; Padding-Bottom:2; Padding-Left:0; Padding-Right:0; Margin-Top:1; Margin-Bottom:1; Margin-Left:1; Margin-Right:1; BackGround-Color:Transparent; } TABLE { Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:Black; Margin-Top:-1; } </STYLE> <script Language='VBScript'> Const MY_COMPUTER = &H11& '-> Resize And Move Window Dim Wth :Wth = int(500) Dim Hht :Hht = int(275) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2)) '-> Objects For Run Time Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Shl :Set Shl = CreateObject("Shell.Application") '-> Varible To Check imagex.exe = True Dim ChkImageX '-> Window On Load Function Function Window_onLoad() If Fso.FileExists("imagex.exe") Then ChkImageX = True End Function '-> Function To Brows For Folder And Return The Folder Path Function FolderPath(MyTxt,Arg) Dim Brows Set Brows = Shl.BrowseForFolder(0,MyTxt, 0, MY_COMPUTER) '-> Press The Cancel Button If Brows Is Nothing Then MsgBox "User Cancel Process",4128,"User Cancel" Exit Function '-> Press The Ok Button Without Selecting A Folder, Or Root Drive Selected ElseIf InStr(1,Brows.Items.Item,"Computer",1) Or _ Len(Brows.Self.Path) = 3 Then '-> Ask To ReDo Folder Selection If MsgBox("Error Not A Valid Folder Location : " & _ Brows.Items.Item & vbCrLf & _ "Would You Like To Continue The Script?",4132, _ "Continue Or Quit") = 6 Then call FolderPath(MyTxt,Arg) Else Exit Function End If Else '-> Process Folder Selection Select Case Arg Case 1 TxBox1.value = Brows.Self.Path Case 2 TxBox2.value = Brows.Self.Path End Select End If End Function '-> Function Submit Information Button Function CheckTxBox() Dim Chk1, Chk2, Chk3 '-> Check The Textbox For True Or False Values If TxBox1.value <> "" And Fso.FolderExists(TxBox1.value) Then Chk1 = True Else Chk1 = False End If If TxBox2.value <> "" And Fso.FolderExists(TxBox2.value) Then Chk2 = True Else Chk2 = False End If If TxBox3.value <> "" And IsNumeric(TxBox3.value) Then Chk3 = True Else Chk3 = False End If '-> Check For Possible Combination True And False If Chk1 = True And Chk2 = True And Chk3 = True Then If ChkImageX = True Then alert("Processing ImageX Information"& vbcrlf & _ TxBox1.value & vbcrlf & TxBox2.value & vbcrlf & _ TxBox3.value) CreateObject("Wscript.Shell").Run(_ "imagex.exe /apply " & TxBox1.value & " " & _ TxBox3.value & " " & TxBox2.value),1,true Else alert("Error ImageX Missing From Current Directory"& vbcrlf & _ "Can Not Process ImageX Information" & vbcrlf & _ TxBox1.value & vbcrlf & TxBox3.value & vbcrlf & _ TxBox2.value) End If ElseIf Chk1 = False And Chk2 = True And Chk3 = True Then alert("Error Textbox 1, No Values" & vbcrlf & _ "TextBox 1 = " & TxBox1.value & vbcrlf & _ "TextBox 3 = " & TxBox3.value & vbcrlf & _ "TextBox 2 = " & TxBox2.value) ElseIf Chk1 = False And Chk2 = False And Chk3 = True Then alert("Error Textbox 1, Textbox 2 No Values" & vbcrlf & _ "TextBox 1 = " & TxBox1.value & vbcrlf & _ "TextBox 3 = " & TxBox3.value & vbcrlf & _ "TextBox 2 = " & TxBox2.value) ElseIf Chk1 = True And Chk2 = True And Chk3 = False Then alert("Error Textbox 3 Empty Or Not A Number" & vbcrlf & _ "TextBox 1 = " & TxBox1.value & vbcrlf & _ "TextBox 3 = " & TxBox3.value & vbcrlf & _ "TextBox 2 = " & TxBox2.value) ElseIf Chk1 = True And Chk2 = False And Chk3 = False Then alert("Error Textbox 2 No Values, Textbox 3 No Number Or Value" & vbcrlf & _ "TextBox 1 = " & TxBox1.value & vbcrlf & _ "TextBox 3 = " & TxBox3.value & vbcrlf & _ "TextBox 2 = " & TxBox2.value) ElseIf Chk1 = False And Chk2 = False And Chk3 = False Then alert("Error All 3 Textboxes Have No Values" & vbcrlf & _ "TextBox 1 = " & TxBox1.value & vbcrlf & _ "TextBox 3 = " & TxBox3.value & vbcrlf & _ "TextBox 2 = " & TxBox2.value) End If End Function </Script> <BODY> <!-- Container For Wim Path, Target Path, Index Start --> <TABLE Style='Margin-Top:1;'><TD> <!-- Textbox 1 Area Start --> <TABLE><TD Width='337' ID=''> Specify or change source path(the path to you .wim image file). Use the Brows Button to select the folder <BUTTON ID='BtnBrows1' OnClick= 'call FolderPath("Select The Source Wim Folder",1)'> Brows</BUTTON></TD></TABLE> <TABLE><TD><Input Type='text' Size='51' Name='TxBox1'></TD></TABLE> <!-- Textbox 1 Area End --> <!-- Textbox 2 Area Start --> <TABLE><TD Width='337' ID=''> Specify or change target path, where the image will be restored. Use the Brows Button to select the folder. <BUTTON ID='BtnBrows2' OnClick='call FolderPath("Select The Restore Image Folder",2)'> Brows</BUTTON></TD></TABLE> <TABLE><TD><Input Type='text' Size='51' Name='TxBox2'></TD></TABLE> <!-- Textbox 2 Area End --> <!-- Textbox 3 Area Start --> <TABLE><TD Width='289'>Type In The Index Number Of .Wim Image.<BR>Example 2</TD> <TD><Input Type='text' Size='2' Name='TxBox3'></TD></TABLE> <!-- Textbox 3 Area End --> </TD></TABLE> <!-- Container For Wim Path, Target Path, Index End --> <!-- Button Container --> <TABLE Style='Margin-Top:3;'><TD> <BUTTON ID='bSubmit' OnClick='CheckTxBox()'>Subnit</BUTTON> <BUTTON ID='bClose' OnClick='window.Close()'>Close</BUTTON> </TD></TABLE> </BODY> ImageX_Gui.zip -
Read ini file using batch
gunsmokingman replied to Geej's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
My bad here is a Script that will do what you want. Contents of the folderstore.ini I used [Directory] Cabfolder1=C:\Documents and Settings\user name\My Documents Cabfolder2=C:\Documents_and_Settings\user_name\My_Documents Save As Read_Ini_2.vbs '-> Object For Runtime Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> File To Open, Place Full Path If Script Not Is Ame Folder as Ini Dim Ini :Ini = "folderstore.ini" '-> Varibles For Run Time Dim Chk, Loc, Obj, Ts '-> Check For File Exists If Fso.FileExists(Ini) Then '-> Open And Read All Into One Varible Set Ts = Fso.OpenTextFile(Ini,1) Chk = Ts.ReadAll Ts.Close '-> Split The Varible By Line And Loop Threw It For Each Obj In Split(Chk,vbCrLf) '-> Filfter Out Cabfolder1 If InStr(1,Obj,"Cabfolder1",1) Then '-> Split The Line Into Separate Objects Loc = Split(Obj,"=") End If Next Else '-> File Not Found MsgBox "Error 1 Missing : " & Ini WScript.Quit(0) End If '-> Checks For Results If Not Loc(1) = "" Then MsgBox "Confirm : " & Loc(1),4128,"Confirmed Folder" Else MsgBox "Error 2 : Folder path not defined.",4128,"Error 2" End if Rename Read_Ini_2.vbs.txt to Read_Ini_2.vbs to make active Read_Ini_2.vbs.txt -
Read ini file using batch
gunsmokingman replied to Geej's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Try this vbs script to see if it does what you want. Updated Code Fix Save as Read_Ini_2.vbs '-> Object For Runtime Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> File To Open, Place Full Path If Script Not Is Ame Folder as Ini Dim Ini :Ini = "folderstore.ini" '-> Varibles For Run Time Dim Chk, Loc, Obj, Ts '-> Check For File Exists If Fso.FileExists(Ini) Then '-> Open And Read All Into One Varible Set Ts = Fso.OpenTextFile(Ini,1) Chk = Ts.ReadAll Ts.Close '-> Split The Varible By Line And Loop Threw It For Each Obj In Split(Chk,vbCrLf) '-> Filfter Out Cabfolder1 If InStr(1,Obj,"Cabfolder1",1) Then '-> Split The Line Into Separate Objects Loc = Split(Obj,"=") End If Next Else '-> File Not Found MsgBox "Error 1 Missing : " & Ini WScript.Quit(0) End If '-> Checks For Results If Not Loc(1) = "" Then MsgBox "Confirm : " & Loc(1),4128,"Confirmed Folder" Else MsgBox "Error 2 : Folder path not defined.",4128,"Error 2" End if Updated Code Fix -
That true but you could also add something like this to the code posted to get the Date Time Formats from VBS Example Pass Varibles From One Script Langauge To Another Script Langauge Save As Demo_Date_Vbs.cmd @Echo Off CLS Mode 55,7 COLOR F2 Title Pass Varibles Between 2 Script Langauge Set Vbs="%Temp%\Test.vbs" ::Create VBS File With Date Information Echo On Error Resume Next > %Vbs% Echo Dim Act :Set Act = Createobject("Wscript.Shell") >> %Vbs% Echo Dim Fso :Set Fso = Createobject("Scripting.FileSystemObject") >> %Vbs% Echo Dim Ts >> %Vbs% Echo Set Ts = Fso.CreateTextFile(Act.ExpandEnvironmentStrings("%Temp%\Temp.cmd")) >> %Vbs% Echo Ts.WriteLine "Set mName=" ^& MonthName(Month(Now),False) >> %Vbs% Echo Ts.WriteLine "Set mDay=" ^& WeekdayName(Weekday(Now),False) >> %Vbs% Echo Ts.WriteLine "Set mDate=" ^& "%%mName%%" ^& "," ^& "%%mDay%%" ^&_ >> %Vbs% Echo " " ^& Day(Date) ^& "," ^& Year(Date) >> %Vbs% Echo Ts.Close >> %Vbs% Call "%Vbs%" Call "%Temp%\Temp.cmd" Del "%Vbs%" Del "%Temp%\Temp.cmd" Echo. Echo Cmd To VBS To Cmd Results Echo Month Name = %mName% Echo Day Name = %mDay% Echo Full Date = %mDate% Echo. pause Change Demo_Date_Vbs.cmd.txt to Demo_Date_Vbs.cmd to make active Demo_Date_Vbs.cmd.txt
-
You could use a VBS script to run the batch file without any cmd promt window showing Example VBS CreateObject("Wscript.Shell").Run _ ("C:\Users\Gunsmokingman\Desktop\TestDemo.cmd"),0,False Example Cmd @Echo Off Echo Hello World > Test.txt Will produce the text file without any cmd promt window showing
-
The first code would replace this code to get the date format. Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Info : '-> Loop To Get User Responce Do Until Info > "" '-> User Input Info = InputBox("Type In The Date Format Month/Date/Year" & _ "Or Just Type Exit Or Quit To Do Nothing.") '-> User Cancel If InStr(1,Info,"quit" ,1) Or InStr(1,Info,"exit" ,1) Then Act.Popup "User Cancel Script, Preparing To Close", 4,"User Input",4128 WScript.Quit End If '-> Process User Input If Not Info = "" Then Act.Popup "User Input = " & Info, 4,"User Input",4128 Exit Do End If Loop
-
CMD: Delete Empty Line
gunsmokingman replied to Caml Light's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Perhaps try this @echo Off ECHO=HELLO>file.txt -
CMD Batch: Get Time
gunsmokingman replied to Caml Light's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
There are a variety of programming langauges that you could use. Myself I can write in VBS and Vb.net ok, understand Java Script You could also do a Google or Bing Search in C programming . -
Perhaps try this code, this is only a guess at what you want. Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") Dim Ip, Z1, Z2, i Dim shell, counter Set shell=createobject("wscript.shell") Set sysInfo = CreateObject("ADSystemInfo") '-> Start Loop For Each Obj in Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=1",,48) If not isNull(Obj.IPSubnet) Then If not isNull(Obj.IPAddress) Then Z1 = Join(Obj.IPAddress, ",") If Len(Z1) <= 15 Then Ip = Z1 ElseIf Len(Z1) >= 16 Then Z2 = Split(Z1, ",") Ip = Z2(0) End If End If End If Next '-> End Loop Process One Piece Of Info Only '-> Check Only The Single Result If Ip > "194.7.23.199" And Ip < "194.7.23.255" Or _ Ip > "192.168.180.99" And Ip < "192.168.180.200" Or _ Ip > "192.168.181.99" And Ip < "192.168.181.200" And _ InStr(sysInfo.ComputerName, "OU=" & SBX) > 0 Then shell.run("\\SERVER\NETLOGON\Other\pstbackup\Check.bat") Elseif Ip > "192.168.199.109" And Ip < "192.168.199.161" And _ InStr(sysInfo.ComputerName, "OU=" & SB) > 0 Then shell.run("\\SERVER\NETLOGON\Other\pstbackup\Check.bat") End If
-
Mac Changer
gunsmokingman replied to arlanne2's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here is a Vb.Net 2008 app that list all Network Adaptors And there Mac Address. Code Public Class Form1 Dim Wmi = GetObject("winmgmts:\\.\root\CIMV2") ''' <summary> ''' Load Network Adaptor Info ''' </summary> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Col = Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapter") For Each Obj In Col Try If Obj.AdapterTypeId = 0 Then ComboBox1.Items.Add(Obj.Name) End If Catch ex As Exception End Try Next End Sub ''' <summary> ''' Combobox1 Selection Made ''' </summary> Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Dim Col = Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapter") If ListBox1.Items.Count = 1 Then ListBox1.Items.Clear() End If For Each Obj In Col Try If Obj.AdapterTypeId = 0 And Obj.Name = ComboBox1.SelectedItem Then ListBox1.Items.Add(Obj.MACAddress) End If Catch ex As Exception End Try Next End Sub End Class Source Code Zip Demo_WmiNetwork.zip -
mac=Inputbox("Enter MAC here","EXAMPLE","001f1f658279") ie.navigate("http://169.254.1.1/main.cgi?mac_esn=(I WANT TO INSERT THE MAC HERE)a&catindex=3&pageindex=1&Session=1979932169") mac=Inputbox("Enter MAC here","EXAMPLE","001f1f658279") ie.navigate("http://169.254.1.1/main.cgi?mac_esn=(mac)a&catindex=3&pageindex=1&Session=1979932169") If You Need To Have Quotes Around "mac" Chr(34) = " mac=Inputbox("Enter MAC here","EXAMPLE","001f1f658279") ie.navigate("http://169.254.1.1/main.cgi?mac_esn=(Chr(34) & mac & Che(34))a&catindex=3&pageindex=1&Session=1979932169")
-
Here is a HTA using VBS script, it has 8 textboxes <!-- Created By Gunsmokingman Aka Jake1Eye 12:05 PM September-20-11 --> <TITLE>Demo User Input</TITLE> <HTA:APPLICATION ID="Demo User Input" APPLICATIONNAME="DemoUserInput" Border='outset' BORDERSTYLE ='complex' INNERBORDER ='Yes' CAPTION="Yes" MaximizeButton='No' MinimizeButton='No' Scroll='No' SCROLLFLAT ='No' SingleInstance='Yes' ShowInTaskbar='No' SysMenu='No' /> <STYLE Type='text/css'> Body { Font-Size:9.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:Black; BackGround-Color:Transparent; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#ece6e0',EndColorStr='#c0bab4'); Margin-Top:21; Margin-Bottom:1; Margin-Left:4; Margin-Right:4; Padding-Top:1; Padding-Bottom:1; Padding-Left:4; Padding-Right:4; Text-Align:Center; Vertical-Align:Top; Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; } BUTTON { Cursor:Hand; Height:19; Width:69; Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:#001141; Text-Align:Center; Vertical-Align:Middle; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='AliceBlue',endColorStr='LightSlateGray'); Border-Top:0px Transparent; Border-Bottom:0px Transparent; Border-Left:0px Transparent; Border-Right:0px Transparent; Padding-Top:0; Padding-Bottom:2; Padding-Left:0; Padding-Right:0; Margin-Top:1; Margin-Bottom:1; Margin-Left:1; Margin-Right:1; BackGround-Color:Transparent; } TABLE { Font-Size:8.25pt; Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Color:Black; Margin-Top:-1; } </STYLE> <script Language='VBScript'> '-> Resize And Move Window To Center Dim Wth :Wth = int(525) Dim Hht :Hht = int(335) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2)) '-> Function For Submit Button Function UserInput() If TxBox1.value = "" And TxBox2.value = "" And _ TxBox3.value = "" And TxBox4.value = "" And _ TxBox5.value = "" And TxBox6.value = "" And _ TxBox7.value = "" And TxBox8.value = "" Then alert("No Input Was Found In Any Of The Textboxes") Else If Not TxBox1.value = "" Then TxBox1.value = TxBox1.value Else TxBox1.value = "No User Input For Textbox 1" End If If Not TxBox2.value = "" Then TxBox2.value = TxBox2.value Else TxBox2.value = "No User Input For Textbox 2" End If If Not TxBox3.value = "" Then TxBox3.value = TxBox3.value Else TxBox3.value = "No User Input For Textbox 3" End If If Not TxBox4.value = "" Then TxBox4.value = TxBox4.value Else TxBox4.value = "No User Input For Textbox 4" End If If Not TxBox5.value = "" Then TxBox5.value = TxBox5.value Else TxBox5.value = "No User Input For Textbox 5" End If If Not TxBox6.value = "" Then TxBox6.value = TxBox6.value Else TxBox6.value = "No User Input For Textbox 6" End If If Not TxBox7.value = "" Then TxBox7.value = TxBox7.value Else TxBox7.value = "No User Input For Textbox 7" End If If Not TxBox8.value = "" Then TxBox8.value = TxBox8.value Else TxBox8.value = "No User Input For Textbox 8" End If alert( "Result From Textboxes Demo" & vbcrlf & _ "Textbox 1 = " & TxBox1.value & vbcrlf & _ "Textbox 2 = " & TxBox2.value & vbcrlf & _ "Textbox 3 = " & TxBox3.value & vbcrlf & _ "Textbox 4 = " & TxBox4.value & vbcrlf & _ "Textbox 5 = " & TxBox5.value & vbcrlf & _ "Textbox 6 = " & TxBox6.value & vbcrlf & _ "Textbox 7 = " & TxBox7.value & vbcrlf & _ "Textbox 8 = " & TxBox8.value) End If End Function </Script> <BODY> <!-- Textboxes Container --> <TABLE Style='Margin-Top:1;'><TD> <!-- Textbox 1 --> <TABLE><TD Width='180'>Type In First Name</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox1'></TD></TABLE> <!-- Textbox 2 --> <TABLE><TD Width='180'>Type In Middle Name</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox2'></TD></TABLE> <!-- Textbox 3 --> <TABLE><TD Width='180'>Type In Last Name</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox3'></TD></TABLE> <!-- Textbox 4 --> <TABLE><TD Width='180'>Type In Your Street Address</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox4'></TD></TABLE> <!-- Textbox 5 --> <TABLE><TD Width='180'>Type In The City Name</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox5'></TD></TABLE> <!-- Textbox 6 --> <TABLE><TD Width='180'>Type In State Or Province</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox6'></TD></TABLE> <!-- Textbox 7 --> <TABLE><TD Width='180'>Type In Country Name</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox7'></TD></TABLE> <!-- Textbox 8 --> <TABLE><TD Width='180'>Type In Postal Or Zip Code</TD> <TD><Input Type='text' Size='40' Class='' Name='TxBox8'></TD></TABLE> </TD></TABLE> <!-- Button Container --> <TABLE Style='Margin-Top:3;'><TD> <BUTTON ID='Btn01' OnClick='UserInput()'>Submit</BUTTON> <BUTTON ID='Btn02' OnClick='window.Close()'>Close</BUTTON> </TD></TABLE> </BODY> Demo_UserInput.zip
-
This is how you would code in Vb.net 2008 for deleting the contents without deleting the application. Public Class Form1 Dim Cd = My.Computer.FileSystem.CurrentDirectory Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For Each i In My.Computer.FileSystem.GetFiles(Cd) If InStr(1, i, "DelContents.exe", 1) Then ' This Make Sure The DelContents.exe Is Not Deleted Else My.Computer.FileSystem.DeleteFile(i.ToString) End If Next For Each f In My.Computer.FileSystem.GetDirectories(Cd) My.Computer.FileSystem.DeleteDirectory(f, _ FileIO.UIOption.OnlyErrorDialogs, _ FileIO.RecycleOption.DeletePermanently) Next End Sub End Class Source Code
-
Here is the VBS way of doing what you want, it will delete all sub folders and files in the parent directory and leave this script Save As Delete_Contents.vbs Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Col, Obj, Str '-> Loop To Get Script Name Only For Each Obj In Split(WScript.ScriptFullName,"\") Str = Obj Next '-> Loop To Delete Files In Current Directory For Each Col In Fso.GetFolder(".").Files '-> Filter So You Dont Delete This File If Not LCase(Col.Path) = LCase(WScript.ScriptFullName) Then Fso.DeleteFile Col.Path, True End If Next '-> Function To Loop Threw Parent Folder '-> And All Sub Folders Recursive(Fso.GetFolder(".")) Function Recursive(Folder) On Error Resume Next For Each Obj In Folder.SubFolders If Not LCase(Obj.Path) = LCase(Replace(WScript.ScriptFullName,Str,"")) Then Fso.DeleteFolder Obj End If Recursive(Obj) Next End Function Change Delete_Contents.vbs.txt to Delete_Contents.vbs to make active. Delete_Contents.vbs.txt
-
Here a script using WMI Win32_SystemEnclosure with a list of retuen values Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Dim Arg, Col, Obj For Each Col In Wmi.ExecQuery("Select * from Win32_SystemEnclosure") For Each Obj In Col.ChassisTypes Select Case Obj Case 1 :Arg = "Other" Case 2 :Arg = "Unknown" Case 3 :Arg = "Desktop" Case 4 :Arg = "Low Profile Desktop" Case 5 :Arg = "Pizza Box" Case 6 :Arg = "Mini Tower" Case 7 :Arg = "Tower" Case 8 :Arg = "Portable" Case 9 :Arg = "Laptop" Case 10 :Arg = "Notebook" Case 11 :Arg = "Handheld" Case 12 :Arg = "Docking Station" Case 13 :Arg = "All-in-One" Case 14 :Arg = "Sub-Notebook" Case 15 :Arg = "Space Saving" Case 16 :Arg = "Lunch Box" Case 17 :Arg = "Main System Chassis" Case 18 :Arg = "Expansion Chassis" Case 19 :Arg = "Sub-Chassis" Case 20 :Arg = "Bus Expansion Chassis" Case 21 :Arg = "Peripheral Chassis" Case 22 :Arg = "Storage Chassis" Case 23 :Arg = "Rack Mount Chassis" Case 24 :Arg = "Sealed-Case PC" Case Else Arg = "Unknown" End Select Next Next WScript.Echo " Type = " & Arg