Jump to content

gunsmokingman

Super Moderator
  • Posts

    2,296
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Canada

Everything posted by gunsmokingman

  1. Here is a VBS example of moving a folder with spaces in the name to another with folder with spaces in it name. Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FolderExists("C3 D4") Then If Fso.FolderExists("A1 B2") Then Fso.MoveFolder "A1 B2", "C3 D4\A1 B2" End If End If
  2. I have now updated the HTA 1:\ Clean up the code 2:\ Added a choice to run VBS with either Cscript or Wscript engine 3:\ Replaced the directory search with a search of all local drives <!-- Coded By Gunsmokingman Aka Jake1eye Updated February-13-15 --><TITLE>HTA Multi Editor</TITLE><HTA:APPLICATION ID='HTA_ME' Scroll='Yes' SCROLLFLAT ='Yes' SingleInstance='Yes' SysMenu='Yes' ShowInTaskBar='Yes' MaximizeButton='No' MinimizeButton='Yes' Border='Thick' BORDERSTYLE ='complex' INNERBORDER ='Yes' Caption='Yes' WindowState='Normal' APPLICATIONNAME='Gsm_ME' Icon='%SystemRoot%\explorer.exe'><STYLE Type="text/css"> Body{ BackGround-Color:#fdf7f1;Text-Align:Center;Vertical-Align:Top; Font-Size:8.05pt;Font-Weight:Bold;Color:#001254; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Margin-Top:1;Margin-Bottom:1;Margin-Left:4;Margin-Right:4; Padding-Top:1;Padding-Bottom:1;Padding-Left:4;Padding-Right:4; Border-Top:2px Solid #a6a29e;Border-Bottom:3px Solid #cbc7c3; Border-Left:2px Solid #b2aeaa;Border-Right:3px Solid #bcb8b4; } BUTTON{ Width:101pt;Height:13pt;Cursor:Hand; Font-Size:8.05pt;Font-Weight:Bold;Color:#112253; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorSTR='#bcdeff',endColorSTR='#335599'); Padding-Top:1;Padding-Bottom:2;Margin-Left:1pt;Margin-Right:1pt; Border-Top:1px TransParent;Border-Bottom:2px TransParent; Border-Left:1px TransParent;Border-Right:2px TransParent; } TD{ Text-Align:Center;Font-Size:7.95pt;Font-Weight:Bold;Color:#5E5E5E; Margin-Top:1;Margin-Bottom:1; } TD.T1{ Text-Align:Left;Width:39;Font-Size:7.95pt;Font-Weight:Bold;Color:#5E5E5E; Margin-Top:1;Margin-Bottom:1; }</STYLE><SCRIPT LANGUAGE="VBScript"> Const WINDOW_HANDLE = 0 ,OPTIONS = 0,MY_COMPUTER = &H11& '-> Resize And Move Window Dim Wth :Wth = int(925) Dim Hht :Hht = int(575) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))'-> Object For Runtime Dim Shl :Set Shl = CreateObject("Shell.Application") Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Dim C1, c34, Cmd1, Ext, Folder, FItem, i, Obj, Time1 :c34 = Chr(34) Dim Msg1 :Msg1="Select The File Type That You Want To List." Dim Msg2 :Msg2="<FONT Style='Color:#Ad1111;Margin-Top:3;'>" & _ "This may appear to not be responding, while the query is active! " & _ "This is the normal and expected occurance.</FONT>"'-> Window OnLoad Function Window_onLoad() self.Focus() :Txt1.innerHTML=Msg1 :Path.innerHTML = chr(160) End Function'-> File Type Selection Function CheckFileType() Dim j :j = 1 If FType(0).checked Then Ext = "cmd" :j=2 If FType(1).checked Then Ext = "hta" :j=2 If FType(2).checked Then Ext = "inf" :j=2 If FType(3).checked Then Ext = "ini" :j=2 If FType(4).checked Then Ext = "reg" :j=2 If FType(5).checked Then Ext = "vbs" :j=2 If FType(6).checked Then Ext = "txt" :j=2 if j = 1 Then Ext = "Nothing Selected" End Function'-> No File Selected Error Message Function NoFileSelected() alert(" There Was Not A File Type Selected" & vbcrlf & _ "You must select A File Type To Search For.") End Function'-> Clear Left Side Text List Function UpdateList() For Each Obj In TxtFile.Options :Obj.RemoveNode :Next Path.innerHTML = chr(160) End Function'-> Save Any Changes Function SaveMyChanges() Dim TS If Contents.Value = "" Then Else Set Ts = Fso.CreateTextFile(TxtFile.Value) TS.WriteLine Contents.Value Ts.Close End If Exit Function End Function'-> Select From List And Fill Main Text Area Function ReadFile() On Error Resume Next Set objFile = Fso.OpenTextFile(TxtFile.Value) strContents = objFile.ReadAll objFile.Close Contents.Value = strContents Path.innerHTML=TxtFile.Value Exit Function End Function'-> Brows For Dailog To Folder To search Function BrowsFor() CheckFileType() If instr(Ext,"Nothing Selected") Then NoFileSelected() Else Set Folder = Shl.BrowseForFolder(0, "Select a folder:", 0, MY_COMPUTER) If Folder Is Nothing Then Exit Function Else Contents.Value="" Txt1.innerHTML=Msg2 Time1 = window.setTimeout("Querry1", 2000, "VBScript") End If End If End Function'-> Main Query For Single Folder Function Querry1() Set FItem = Folder.Self UpdateList() For Each Obj In Fso.GetFolder(FItem.Path).Files If Right(Instr(Obj.Path,Ext),3) Then Call AddToList(Obj.Name,Obj.Path) End If Next C1=0 Txt1.innerHTML=Msg1 TimerOut() End Function'-> Start Auto Search Function Function AllDrives() CheckFileType() Contents.Value="" Txt1.innerHTML=Msg2 Time1 = window.setTimeout("Querry2", 2000, "VBScript") End Function'-> Main Query For All Local Drives Function Querry2() UpdateList() Dim Col :Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where Extension = '"&Ext&"'") If Col.count = 0 Then MsgBox "Query Results Is Zero Type Found For This Type : " & A1 , 4128, "No File Type Found" Else For Each Obj in Col If InStr(Obj.Path,"windows") Or InStr(Obj.Path,"program") Then Else Call AddToList(Obj.FileName,Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension) End If Next End If C1=0 Txt1.innerHTML=Msg1 TimerOut() End Function'-> Add To List Box Function AddToList(N,P) C1 = C1 + 1 Set i = Document.createElement("OPTION") i.Text = N i.Value = P If C1 Mod 2 Then i.style.backgroundcolor = "#C9C9C9" i.style.color = "#3A3A3A" Else i.style.backgroundcolor = "#E9E9E9" i.style.color = "#235779" End If TxtFile.Add(i) End Function'-> Clear Select And Path Start Function ClearReset() UpdateList() Contents.Value = "" Path.innerHTML = Chr(160) End Function'-> Run Select Item Function RunCmdPromt() If TxtFile.Value = "" Then alert("There was nothing to run") Else If FType(0).checked Then Cmd1 = "cmd.exe /c " & c34 & TxtFile.Value & c34 If FType(1).checked Then Cmd1 = "mshta.exe " & c34 & TxtFile.Value & c34 If FType(5).checked Then If confirm("Press Ok to run the VBS script using Cscript.exe, " &_ "or press Cancel to run the VBS script using Wscript.exe") = True Then Cmd1 = "cscript.exe " & c34 & TxtFile.Value & c34 Else Cmd1 = "wscript.exe " & c34 & TxtFile.Value & c34 End If End If If FType(2).checked Or FType(3).checked Or FType(4).checked Or FType(6).checked Then Cmd1 = "notepad.exe " & c34 & TxtFile.Value & c34 End If Act.Run(Cmd1),1,True End If End Function '-> Clear The Timer Function TimerOut() Time1 = window.clearTimeout() End Function </SCRIPT><BODY>HTA Multi Editor<DIV ID='Txt1' Style='Color:;Margin-Top:3;'> </DIV><!-- Select File Type --><TABLE width="50%"> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Cmd</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Hta</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Inf</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Ini</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Reg</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Vbs</TD> <TD STYLE='Width:14;'><INPUT Type='Radio' Name='FType'></TD><TD Class='T1'>Txt</TD></TABLE><TABLE width="100%" Style='Margin-Top:3px;Margin-Bottom:3px;' Border='1'><TR><!-- Display Item Name --><TD width="25%" valign="top"> <select style="Width:100%;Font-Family:Lucida Console;Font-Size:7.95pt;Font-Weight:Bold;" size="35" Name="TxtFile" OnChange="ReadFile()"></select></TD><!--Display File And Edit --><TD width="75%" valign="top"> <textarea Style='Width:100%;Font-Family:Lucida Console;Font-Size:7.95pt;Font-Weight:Bold;' Name="Contents" rows="35" cols="100" OnChange='SaveMyChanges()'></textarea></TD></TR></TABLE><!-- Display Item Path --><SPAN ID='Path' > </SPAN><!-- Button Table Start --><TABLE Style='Margin-Top:3px;Margin-Bottom:3px;' Border='1' Align='Center'><!-- Single Folder Button --><TD><BUTTON OnClick='BrowsFor()'>Single Folder</BUTTON></TD><!-- Auto Search Button --><TD><BUTTON Title='Searches All The Local Drives For Selected File Type' OnClick='AllDrives()'>Auto Search</BUTTON></TD><!-- >Clear Query Button --> <TD><BUTTON OnClick='ClearReset()'>Clear Query Box</BUTTON></TD><!-- Run Selected Button --> <TD><BUTTON OnClick='RunCmdPromt()'>Process Item</BUTTON></TD></TABLE></BODY>Code Fixes Or Updates1:\ Fixed a couple of errors I missed in the Single Folder Button 2:\ Updated Query1 and Query2 to use a single function to populate the left side list. Old Query 1 and 2 Function '-> Main Query For Single Folder Function Querry1() Set FItem = Folder.Self UpdateList() For Each Obj In Fso.GetFolder(FItem.Path).Files If Right(Instr(Obj.Path,Ext),3) Then C1 = C1 + 1 Set i = Document.createElement("OPTION") i.Text = Obj.Name i.Value = Obj.Path If C1 Mod 2 Then i.style.backgroundcolor = "#C9C9C9" i.style.color = "#3A3A3A" Else i.style.backgroundcolor = "#E9E9E9" i.style.color = "#235779" End If TxtFile.Add(i) End If Next C1=0 Txt1.innerHTML=Msg1 TimerOut() End Function'-> Main Query For All Local Drives Function Querry2() UpdateList() Dim Col :Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where Extension = '"&Ext&"'") If Col.count = 0 Then MsgBox "Query Results Is Zero Type Found For This Type : " & A1 , 4128, "No File Type Found" Else For Each Obj in Col If InStr(Obj.Path,"windows") Or InStr(Obj.Path,"program") Then Else 'WScript.Echo Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension C1 = C1 + 1 Set i = Document.createElement("OPTION") i.Text = Obj.FileName i.Value = Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension If C1 Mod 2 Then i.style.backgroundcolor = "#C9C9C9" i.style.color = "#3A3A3A" Else i.style.backgroundcolor = "#E9E9E9" i.style.color = "#235779" End If TxtFile.Add(i) End If Next End If C1=0 Txt1.innerHTML=Msg1 TimerOut() End FunctionNew Query 1 and 2 Function '-> Main Query For Single Folder Function Querry1() Set FItem = Folder.Self UpdateList() For Each Obj In Fso.GetFolder(FItem.Path).Files If Right(Instr(Obj.Path,Ext),3) Then Call AddToList(Obj.Name,Obj.Path) End If Next C1=0 Txt1.innerHTML=Msg1 TimerOut() End Function'-> Main Query For All Local Drives Function Querry2() UpdateList() Dim Col :Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where Extension = '"&Ext&"'") If Col.count = 0 Then MsgBox "Query Results Is Zero Type Found For This Type : " & A1 , 4128, "No File Type Found" Else For Each Obj in Col If InStr(Obj.Path,"windows") Or InStr(Obj.Path,"program") Then Else Call AddToList(Obj.FileName,Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension) End If Next End If C1=0 Txt1.innerHTML=Msg1 TimerOut() End Function'-> Add To List Box Function AddToList(N,P) C1 = C1 + 1 Set i = Document.createElement("OPTION") i.Text = N i.Value = P If C1 Mod 2 Then i.style.backgroundcolor = "#C9C9C9" i.style.color = "#3A3A3A" Else i.style.backgroundcolor = "#E9E9E9" i.style.color = "#235779" End If TxtFile.Add(i) End FunctionUpdated Code ZipHtaEditor.zip
  3. NewScriptJunkie here are 2 VBS scripts tp help you find out the file types. Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Obj'-> Loop Threw The Files In Parent Folder Only For Each Obj In Fso.GetFolder(".").Files'-> Echo Out The File Type WScript.Echo Obj.Type Next Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Col, Obj'-> Loop Threw The Files In Parent Folder Only For Each Obj In Fso.GetFolder(".").Files'-> Collect All The File Type Col = Col & vbCrLf & Obj.Type Next '-> Display All File Type In One Self Closing Messagebox CreateObject("WScript.Shell").Popup _ "VBS File Type Return" & vbCrLf & Col,10,"Results Of Type Script",4128
  4. I have made 2 changes in the ListFiles Function 1:\ It now process either WMA or MP3 files Old If Col.type = "Windows Media Audio file" Then New If Col.type = "Windows Media Audio file" Or Col.type = "MP3 Format Sound" Then 2:\ Replace the replace Old D2 = D1 & "\" & Replace(Obj(2),")).wma","") New D2 = D1 & "\" & Left(Obj(2),Len(Obj(2))-6) Updated Function Function ListFiles(D) Dim D1, D2, D3 For Each Col In D.Files If Col.type = "Windows Media Audio file" Or Col.type = "MP3 Format Sound" Then If InStr(Col,"(") Then'-> Where The Name Get Split And Then Make The Folder Name Obj = Split(Col.Name,"(") D1 = Loc & "\"& Obj(1) ' WScript.Echo D1 If Not Fso.FolderExists(D1) Then Fso.CreateFolder(D1) D2 = D1 & "\" & Left(Obj(2),Len(Obj(2))-6) ' WScript.Echo D2 If Not Fso.FolderExists(D2) Then Fso.CreateFolder(D2) D3 = D2 & "\" & Obj(0) If Not Fso.FolderExists(D3) Then Fso.CreateFolder(D3) ' WScript.Echo D3 Fso.CopyFile Col.Path, D3 & "\" & Col.Name, True Fso.DeleteFile Col,True End If End If Next MsgBox "Completed Procssing Wma Files In This Folder" & vbCrLf & _ Fso.GetFolder(".").Path,4128,"Music Processing" End FunctionQuote NewScriptJunkie Is there a type video or txt version of the same?Just create a script that echos out the Col.type and than use that in the if statement.
  5. What you want done is a very complex problem, I have a script that I wrote to process my music files. I Have a very specific way of naming my files Babe I'm Gonna Leave You(Led Zeppelin(Rock_1969)).wma I Split The name using ( to split the name into 3 parts Group\Gene And Year\Song Name Before Script After Script Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Arg, Col, Dir, Drv, Loc, Obj'-> Start Script With Folder Paths And No Drive Letters ChkForFolder("\Music\Wma")'-> The Results From ChkForFolder Then'-> If True List The Files In Parent Folder If Arg = True Then MsgBox "Preparing To Process The Wma Files" & vbCrLf & _ Fso.GetFolder(".").Path,4128,"Music Processing" ListFiles(Fso.GetFolder(".")) Else ReportChkFolder(Arg) End If '-> Function For Script Function ChkForFolder(Chk) For Each Drv In Fso.Drives If Drv.IsReady = True Then If Fso.FolderExists(Drv & Chk) Then Loc = Drv & Chk Arg = True Exit For Else Arg = False Obj = Obj & vbCrLf & Drv & Chk End If End If Next End Function '-> Function ReportChkFolder(A) If A = False Then Obj = "Error Pathways Do Not Exist" & vbCrLf & Obj MsgBox Obj,4128,"Error" End If WScript.Quit End Function Function ListFiles(D) Dim D1, D2, D3 For Each Col In D.Files If Col.type = "Windows Media Audio file" Then If InStr(Col,"(") Then'-> Where The Name Get Split And Then Make The Folder Name Obj = Split(Col.Name,"(") D1 = Loc & "\"& Obj(1) ' WScript.Echo D1 If Not Fso.FolderExists(D1) Then Fso.CreateFolder(D1) D2 = D1 & "\" & Replace(Obj(2),")).wma","") ' WScript.Echo D2 If Not Fso.FolderExists(D2) Then Fso.CreateFolder(D2) D3 = D2 & "\" & Obj(0) If Not Fso.FolderExists(D3) Then Fso.CreateFolder(D3) ' WScript.Echo D3 Fso.CopyFile Col.Path, D3 & "\" & Col.Name, True Fso.DeleteFile Col,True End If End If Next MsgBox "Completed Procssing Wma Files In This Folder" & vbCrLf & _ Fso.GetFolder(".").Path,4128,"Music Processing" End Function Rename ProcessMusicFiles_V1.vbs.txt to ProcessMusicFiles_V1.vbs make activeProcessMusicFiles_V1.vbs.txt
  6. You could use less of this stuff Set objFolder = objFSO.GetFolder("T:\input") Set colFiles = objFolder.Files For Each objFile in colFilesYou could do this with the same results For Each Obj in objFSO.GetFolder("T:\input").FilesThis If Not objFSO.FolderExists(strFolderName) Then Set objNewFolder = objFSO.CreateFolder(strFolderName) End IfWith this If Not objFSO.FolderExists(strFolderName) Then objFSO.CreateFolder strFolderName End IfI am not sure about your question.
  7. Here is a way of doing what you want, only using a VBS script '-> Wmi ObjectDim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\cimv2")'-> Varibles For RuntimeDim Col, i, Ip, Obj'-> Array To Hold All The IP AddressesIp = Array("127.0.0.1","192,123,55,1","127.0.0.24","123.55.72.123")'-> Start First Loop Threw IP For Each i In Ip '-> Passing i As Ip Address To Be Ping Set Col = Wmi.ExecQuery("Select * From Win32_PingStatus where Address = '"&i&"'")'-> Second Loop To Ping Ip Address For Each Obj in Col If IsNull(Obj.StatusCode) Or Obj.StatusCode<>0 Then'-> Code Here For Computer That Does Not Respond Wscript.Echo "Computer Ping Missing : " & i Else'-> Code Here When The Computer Does Respond WScript.Echo "Computer Ping Confirm : " & i End If Next Next
  8. if you have any questions or problems with VBS, Js, PowerShell post them here and we will try to help.
  9. Here are some links to help you with your scripts MoveHere Shell.Windows method To add copy to a filename if exists and no dialog to ask yes no Fld.MoveHere Obj.Path,24+Bar
  10. Try this VBS script and see if it what you want, it will move all the folders in the parent folder to Set Fld folder and leave the parent folder empty. Const Bar = &H0&'-> Objects For ScriptDim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Shl :Set Shl = CreateObject("Shell.Application")Dim Fld, Obj'-> Fso.GetFolder(".") Makes The Folder Whee The Script Is Located '-> The Parent Folder. Place A Pathway Fso.GetFolder("Drive:\FolderName")'-> To Use Another Folder For Each Obj In Fso.GetFolder(".").SubFolders '-> Check To Make Sure It Not In The Pth Folder Set Fld = Shl.NameSpace("C:\Users\Gunsmokingman\Desktop\ToThere") If Not Fld Is Nothing Then 'WScript.Echo Obj.Path Fld.MoveHere Obj.Path,Bar End If Next'-> End Of Script Message Closes Automatically After 5 Seconds CreateObject("Wscript.Shell").Popup _ "Script Completed",5,"End Of Script",4128
  11. Perhaps a VBS script might work, place the below script in the folder and it should open Test.txt if it there. Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FileExists("Test.txt") Then WScript.Echo "Confirm : " & _ Replace(WScript.ScriptFullName,WScript.ScriptName,"") & "Test.txt" CreateObject("Wscript.Shell").Run("Test.txt"),1,False Else WScript.Echo "Missing : " & _ Replace(WScript.ScriptFullName,WScript.ScriptName,"") & "Test.txt" End If Contents Of Test.txtTesting $ in pathway.
  12. Here is the VBS way of searching the Parent folder and all it subfolder and a filter to get the require extension. Then it collects all the files add them to a Dictionary Object, then selects a random item from the dictionary and copy the file to 1.vbs. I have included comments to help edit the code. Dim Dic :Set Dic = CreateObject("Scripting.Dictionary")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Col, Obj'-> Uncomment Search(Fso.GetFolder(".")) Use Only If Script Is In The '-> Same Folder That You Want To Search All Folders And Sub Folders Search(Fso.GetFolder("."))'-> Uncomment Place Full Path Search(Fso.GetFolder("Drive:\FOLDER\ANOTHERFOLDER"))'-> This Will Then Use That Path As The Parent Folder To Search Threw All The Folders ' Search(Fso.GetFolder("Drive:\FOLDER\ANOTHERFOLDER"))'-> Start The Work After The Search Has Collected All The Files Work() Function Search(F) For Each Obj In F.Files'-> Here We Filter Out The File Type Then Add It To The Dictionary'-> Change "vbs" To Extension Than You Need If Not Dic.Exists(Obj) And LCase(Right(Obj,3)) = "vbs" Then Dic.Add Obj.Path, Obj End If Next For Each Col In F.SubFolders Search(Col) Next End Function '-> Selects Dictionary Ramdom File, Then Copy File Function Work() Dim a,b,i '-> Where We Get The Random Item Randomize a = Dic.Count Do b = int(Rnd(1)*a) Loop While b < 1 a = Dic.Items For i = 0 To Dic.Count -1'-> Match Random Item With The Dictionary Item If b = i Then'-> Uncomment If You Want To See The Original FileName Before Rename' WScript.Echo "CopyFile : " & a(i)'-> Uncomment And Change "\\HOMEBETAVISTA\Vista-D\TestCopyRename\1.vbs" To What You Need' Fso.CopyFile a(i), "\\HOMEBETAVISTA\Vista-D\TestCopyRename\1.vbs",True End If Next End Function
  13. All I expected with the Powershell was it to work like the example that all, I did not understand why it would not on Win 7 or Win 10 as is. When I read the link I understood I had to make some changes, which I have choose not to make. I apologise for any my misunderstanding
  14. Yzöwl that code will not work unless the OS has been modified to allow it to work, I am lost to as how that is better. If the code executed like this example that works perfect on Windows 7 without making any changes to the OS. Get-Childitem C:\Windows\*.log So what you are suggesting than is to use code that will only work when you have to modified every computer to allow it to work on. Where as the HTA will always work on any XP, Vista, Win7, Win8, Win10 without modifications
  15. Code I Tried As Test.ps1 #now that WiFi adapter is configured, let's add our hotspot$WifiPassSec = Read-host -Prompt "Enter password for your Wifi, must be at least 8 chars long, complex" -AsSecureString#enable hosted network$WifiPass = ConvertFrom-SecureToPlain $WifiPassSec$SetupHN = "netsh wlan set hostednetwork mode=allow ssid=Rivnet-Wifi key=`"$WifiPass`" keyUsage=persistent`nnetsh wlan start hostednetwork"Invoke-expression $SetupHN$SetupHN = $null$WifiPass = $nullIf it an XP system and Powershell is not installed then the script would failWhen I tested this on Win 10 I had the wrong extension .ps it should of been .ps1. Now when I tried to run the script on Windows 7, using the power shell. What I got running it in the Power Shell ISE for Windows 10
  16. Merry Christmas and may the new years bring you good luck.
  17. Here is a basic HTA template that will return the user input, I used Microsoft Jscript as the language. <TITLE> « Wifi Changer » </TITLE> <HTA:APPLICATION ID="WifiChange" APPLICATIONNAME="WifiC" Border="Thin" BORDERSTYLE ="Complex" Caption="Yes" Icon="%Windir%\explorer.exe" INNERBORDER ="No" MaximizeButton="No" MinimizeButton="Yes" Scroll="No" SCROLLFLAT ="No" SingleInstance="Yes" SysMenu="Yes" WindowState="Normal"/><STYLE Type='text/css'> Body{Font-Size:9.25pt;Font-Weight:Bold;Color:Black; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; BackGround-Color:#EFE9E3;Text-Align:Center;Vertical-Align:Top; Margin-Top:11;Margin-Bottom:1;Margin-Left:4;Margin-Right:4; Padding-Top:1;Padding-Bottom:1;Padding-Left:4;Padding-Right:4; Border-Top:0px Transparent;Border-Bottom:0px Transparent; Border-Left:0px Transparent;Border-Right:0px Transparent; } BUTTON{Cursor:Hand;Height:17pt;Width:35pt; Font-Size:8.25pt;Font-Weight:Bold;Color:#001141; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Text-Align:Center;Vertical-Align:Middle; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='AliceBlue',endColorStr='LightSlateGray'); Border-Top:1px Transparent;Border-Bottom:1px Transparent; Border-Left:1px Transparent;Border-Right:1px Transparent; Padding-Top:0;Padding-Bottom:2;Padding-Left:0;Padding-Right:0; Margin-Top:1;Margin-Bottom:1Margin-Left:1;Margin-Right:1; } .Tx1{Font-Size:8.25pt;Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;} Input{Font-Size:8.25pt;Font-Weight:Bold;Color:#004141;} TD{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;} FONT{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;} FONT.FT1{Font-Size:8.25pt;Font-Weight:Bold;Color:Red;}</STYLE><SCRIPT LANGUAGE='JScript'>//-> Resize And Place In Approx center window.resizeTo(401,125) window.moveTo(screen.availWidth/2-(401/2),screen.availHeight/2-(125/2)) //-> Button Click Function function MyButton1(){ if(Str.value.length==0){alert("Please fill in a wifi password");} else{alert(Str.value);Str.value=""}} </SCRIPT> <BODY> <TABLE> <TD><FONT CLASS=''>Type in the wifi password </FONT></TD> <TD><INPUT Type='Text' ID='Str' Size=28 MAXLENGTH=28></TD> <TD><BUTTON ID='Btn1' OnClick="MyButton1()">Process</BUTTON></TD> </TABLE><TABLE></BODY>
  18. My script that I posted could work for all of Mike88 needs, all he would have to do is fill the array with the Batch files he want to run and then they would be executed. My script does not need to be in the same folder as the file.Type and can be run from anywhere. My goal was to show another way of doing something without the need to hardcode any paths. Here is a Microsoft Jscript that does almost the same thing as the VBS, the difference it does not report missing file in the query. var Act = new ActiveXObject("Wscript.Shell");var Wmi = GetObject("winmgmts:\\\\.\\root\\cimv2")var A = new Array("Test.cmd","Test.exe","Test.msi")var Rpt="", V1=""; c34=String.fromCharCode(34); c92=String.fromCharCode(92) for(var i = 0; i<A.length; i++){ var f =A[i].split(".") Rpt=Rpt+"\n\r"+"Processing : " + A[i]; V1=true var Obj = Wmi.ExecQuery( "Select * from CIM_Datafile Where Extension = '"+f[1]+"' and FileName='"+f[0]+"'") for (var e=new Enumerator(Obj); !e.atEnd(); e.moveNext()){ var s = e.item();F = c34+s.Drive+s.Path+A[i]+c34; if(V1==true){F=Replace(F, c92,c92+c92) V1=false;Rpt=Rpt+"\n\r"+"Installed : " + F; Act.Run("Cmd /c " + F,1,true) }else{Rpt=Rpt+"\n\r"+"Found File : " + F;}}}Act.Popup("\tResults" + "\n\r" + Rpt,300,"Query Results",4128) //--> VBS Script Custom Functions For Text function LCase(str){return str.toLowerCase();} function Left(str, n){return str.substring(0,n)} function Right(str, N){return str.substring(str.length, str.length - N);} function Replace(Arg,R1,R2){var i = Arg.split(""), RTurn for(j=0; j < i.length; j++){RTurn += i[j].replace(R1,R2);} if(Left(LCase(RTurn),"undefined".length)=="undefined"){ return Right(RTurn, RTurn.length-"undefined".length) }else{return RTurn}}
  19. From your point of view, yours will not find every instance of Test.cmd, mine will finds every instance of Test.cmd, regardless of path. Results From Mine ---------------------------Query Results--------------------------- ResultsConfirm : "d:\oem\runonceex\test.cmd"Install : "d:\oem\runonceex\test.cmd"Confirm : "e:\test.cmd"Confirm : "k:\oem\runonceex\Test.cmd"Confirm : "z:\oem\runonceex\test.cmd"Confirm : "z:\oem\runoncex\test.cmd"Confirm : "z:\test.cmd"Confirm : "z:\tempmusic\test.exe"Install : "z:\tempmusic\test.exe"Missing : Test.msi---------------------------OK ---------------------------FileSystemObject with checks for drive isready and FileExists and Execute it only Once Dim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Drv,Rpt, Var, Z :Z="\oem\runonceex\test.cmd"Var = True For Each Drv In Fso.Drives If Drv.IsReady Then If Fso.FileExists(Drv & Z) And Var = True Then Rpt=Rpt&vbCrLf&"Installed File : "&Drv&Z Var=False : Act.Run(Drv & Z),1,true ElseIf Fso.FileExists(Drv & Z) And Var = False Then Rpt=Rpt&vbCrLf&"Found File: "&Drv&Z Else Rpt=Rpt&vbCrLf&"Missing File: "&Drv&Z End If End If Next Act.Popup vbTab & "Results" & vbCrLf & Rpt,300,"Query Results",4128
  20. Here is why VBS is so much more better than CMD please replicate the following script, in CMD Dim A, F, i, Obj, R, V Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Wmi :Set Wmi = GetObject( _ "winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") A = Array("Test.cmd","Test.exe", "Test.msi") For Each i In A F = Split(i,".") V=True Dim Col :Set Col = Wmi.ExecQuery( _ "Select * from CIM_DataFile Where Extension = '"&F(1)&"' And FileName='"&F(0)&"'") If Col.count = 0 Then R = R & vbCrLf & "Missing : " & i Else For Each Obj in Col F = Chr(34)& Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension &Chr(34) R = R & vbCrLf & "Confirm : " & F If V = True Then V = False Act.Run("Cmd /c " & F),1,True R = R & vbCrLf & "Install : " & F End If Next End If Next Act.Popup vbTab & "Results" & vbCrLf & R,300,"Query Results",4128I could code this in MS Jscript Vb.Net and you CMD that is so 1985I forgot you know Powershell, myself I chose not to learn that language but I can read it and just not my cup of tea. Just to note you can add any install switch to each array item This script will only execute each item one time, but will list found file in the final report.
  21. Here is a VBS script that will look only for test.cmd and when found will run the test.cmd Dim Obj Dim Wmi :Set Wmi = GetObject( _ "winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Dim Col :Set Col = Wmi.ExecQuery( _ "Select * from CIM_DataFile Where Extension = 'cmd' And FileName='test'") If Col.count = 0 Then WScript.Echo "Missing : Test.cmd" WScript.Quit Else For Each Obj in Col Wscript.Echo Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension CreateObject("Wscript.Shell").Run("Cmd /c " & _ Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension),1,True Next End ifTested Output, Z my mapped network drive Test.cmd I tested the above script with @Echo Off && CLS && MODE 55,5 && COLOR 8F && TITLE TEST.CMDEcho. && Echo Test Command && ping -n 3 127.0.0.1>nul 1:\ I am not aware of all properties of WMI, other than this will check every available drive, found the file on my map drive 2:\ I set Col properties because it give you a simple way of saying yes only if FILE.EXT than list or do something, if not closes the script. 3:\ You may think it slow but at least I have simple error control with the if something and no need to define a path, this will execute test.cmd anywhere it found.
  22. Here I wrote you this HTA to search for the file it will either say file missing message or fill the list box. When You select an item in the list box it return the name and path to the file <TITLE> « Find File » </TITLE> <HTA:APPLICATION ID="FindFile" APPLICATIONNAME="FFile" Border="Thin" BORDERSTYLE ="Complex" Caption="Yes" Icon="%Windir%\explorer.exe" INNERBORDER ="No" MaximizeButton="No" MinimizeButton="Yes" Scroll="No" SCROLLFLAT ="No" SingleInstance="Yes" SysMenu="Yes" WindowState="Normal"/><STYLE Type='text/css'> Body{Font-Size:9.25pt;Font-Weight:Bold;Color:Black; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; BackGround-Color:#EFE9E3;Text-Align:Center;Vertical-Align:Top; Margin-Top:11;Margin-Bottom:1;Margin-Left:4;Margin-Right:4; Padding-Top:1;Padding-Bottom:1;Padding-Left:4;Padding-Right:4; Border-Top:0px Transparent;Border-Bottom:0px Transparent; Border-Left:0px Transparent;Border-Right:0px Transparent; } BUTTON{Cursor:Hand;Height:19pt;Width:35pt; Font-Size:8.25pt;Font-Weight:Bold;Color:#001141; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS; Text-Align:Center;Vertical-Align:Middle; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='AliceBlue',endColorStr='LightSlateGray'); Border-Top:1px Transparent;Border-Bottom:1px Transparent; Border-Left:1px Transparent;Border-Right:1px Transparent; Padding-Top:0;Padding-Bottom:2;Padding-Left:0;Padding-Right:0; Margin-Top:1;Margin-Bottom:1Margin-Left:1;Margin-Right:1; } .Tx1{Font-Size:8.25pt;Font-Weight:Bold; Font-Family:Segoe Ui, Arial,Tahoma,Comic Sans MS;} Input{Font-Size:8.25pt;Font-Weight:Bold;Color:#004141;} TD{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;} FONT{Font-Size:8.25pt;Font-Weight:Bold;Color:#414141;} FONT.FT1{Font-Size:8.25pt;Font-Weight:Bold;Color:Red;}</STYLE><SCRIPT LANGUAGE='JScript'>//-> Resize And Place In Approx center window.resizeTo(501,225) window.moveTo(screen.availWidth/2-(501/2),screen.availHeight/2-(173/2))//-> Search Button click function MyButton1(){ if(Str.value.length==0){alert("Please fill in a file name");} else{SearchFile(Str.value);}} </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Dim C1, Col, Obj, Wmi, Var'-> Start The WMI Query And Then Add To Select Or No File Found Function SearchFile(F) Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where FileName='" & F & "'") If Col.count = 0 Then alert("Can Not Find This File : " & F) Exit Function Else For Each Obj in Col C1 = C1 + 1 Set Sel = Document.createElement("OPTION") Sel.Text = Obj.FileName & "." & Obj.Extension Sel.Value = Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension If C1 Mod 2 Then Sel.style.backgroundcolor = "#C9C9C9" Sel.style.color = "#3A3A3A" Else Sel.style.backgroundcolor = "#E9E9E9" Sel.style.color = "#235779" End If Found.Add(Sel) Next End If End Function </SCRIPT><BODY> <TABLE> <TD><FONT CLASS=''>Type in the file name with no extension </FONT></TD> <TD><INPUT Type='Text' ID='Str' Size=28 MAXLENGTH=28></TD> <TD><BUTTON ID='Btn1' OnClick="MyButton1()">Search</BUTTON></TD> </TABLE><TABLE> <FONT Class='FT1'> Note the Search Button Query might make the HTA seem like it not reponding, this is the result of the WMI Query and this is normal</FONT></TABLE><TABLE><TD> <select size="1" ID='Found' name="Found" onChange='if(Found.length >= 1){alert(Found.options[Found.selectedIndex].text+"\n\r"+Found.value)}' Class='Tx1'> </select></TD></TABLE></BODY> FindFile.zip
  23. The second script found every instance of test on my local drives and my map drive the input only require the name and no extension. This Test.txt return missing file, where as test return this Being it a WMI based script you could change the query to include the extension, or hard code it to a specific file type. Example
  24. I updated the VBS to include a Inputbox to specify the file name to search all local drives Dim Col, Obj, Str, Wmi :Str = InputBox("Type The Name Of the File To Find") If Str <> "" Then Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set Col = Wmi.ExecQuery("Select * from CIM_DataFile Where FileName='" & Str & "'") If Col.count = 0 Then WScript.Echo "Missing : " & Str WScript.Quit Else For Each Obj in Col Wscript.Echo Obj.Drive & Obj.Path & Obj.FileName & "." & Obj.Extension Next End If Else WScript.Echo "User Cancel" End If Perhaps you missed this You have to change this line in the VBS script and FILE_NAME changed to name you are searching for Just a note that this VBS script does check map drives on the network Test the script using the word test and the results it returned, Z being my map drive
×
×
  • Create New...