Answer» ok im trying to learn winscript its goin alright but i need some help with something
ok this batch code makes 100 COMMAND promts open is there a way to do this with a vbs
for /L %%v in (1,1,100) do start
thanks
another THING i cant find a good site to learn winscript on does anyone know where one is
thanks againWhy anyone would need to do this is beyond me. Try learning about the power and versatility of Windows Script before you attempt such childish games.
Windows Script Host
Code: [Select] Set WshShell = CREATEOBJECT("WScript.Shell") For i = 1 to 100 WshShell.Run "c:\windows\system32\Cmd.exe" Next
Not withstanding all the "Dummy" books, script writing requires some logical thought. ok i need some help understanding this line im trying to put the file name now4.vbs in this but i dont know how to put it in the script looks like this
If InStr(objFile.FileName, "current") Then
where would i add the file name thanksLooking a one line of code is difficult at best and your question is very vague.
First you need to create a reference to the FileSystemObject.
Set fso = CreateObject("Scripting.FileSystemObject")
Next you need a reference to the file.
Set objFile = fso.GetFile("now4.vbs") ' You can put a path on the file name
Your IF statement is in error. There is no FileName property for the file object; use objFile.Name
Now it becomes problematic. If your are looking for the string current within the file label you're not going to find it (in this case) but if you're looking in the files contents you can either read the entire contents of the file with the ReadAll method or read the file line by line. The method for inserting a line in a sequential file is dependent on where the insertion point is... beginning of file, end of file or somewhere in the middle.
Good luck. yea i didnt post the rest of the script b/c i couldnt find it or havent wrote it so here it isopps forgot to add it strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='T:\Act'} Where " _ & "ResultClass = CIM_DataFile")
For Each objFile In colFileList If InStr(objFile.FileName, "current") Then objFile.Delete End If Next
[sigh]
Using WMI to delete a file is a BIT of overkill, but what the *censored*.
Code: [Select] strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='T:\Act'} Where " _ & "ResultClass = CIM_DataFile") For Each objFile In colFileList If InStr(objFile.FileName, "current") Then objFile.Delete objFile.FileName & "." & objFile.Extension End If Next
It warms my heart to see someone taking advantage of the available Windows tools (especially since they are free!).
Good luck. ok where would i add the file name i want to delete in this like if i wanted to dlete now.vbs how would i put ti in i no im suppose to add it somewhere in here i no stupid question but i dont no
For Each objFile In colFileList If InStr(objFile.FileName, "current") Then objFile.Delete ok where would i add the file name i want to delete in this like if i wanted to dlete now.vbs how would i put ti in i no im suppose to add it somewhere in here i no stupid question but i dont no
For Each objFile In colFileList If InStr(objFile.FileName, "current") Then objFile.Delete ok i no this is a stupid question but i need help ok i dont know where to put in the file name of which i want it to dlete. i want to dlete now.vbs but i dont know where to add the name into the script i know it goes osmewhere in here but i dont know where
For Each objFile In colFileList If InStr(objFile.FileName, "current") Then objFile.DeleteYou don't need to specify a file name. The script as written is going out to the t:\act directory and creating a collection of all the file names.
The IF statement checks if the string "current" is present in the file name and deletes it using:
objFile.Delete objFile.FileName & "." & objFile.Extension
Be careful, the WMI service is both COMPLEX and powerful.
Note: Using the FileSystemObject would have been easier and more strightforward.
|