Jump to content

Zabu

Members
  • Posts

    8
  • Joined

  • Last visited

Reputation

0 Neutral

About Zabu

  1. The problem that you are having screwuphead is because I have never seen SyncToy until today. Sorry about the confusion. The correct format that you want to use is (and I used a variable for the job name so it's easier to modify): strJobName = "MyReallyNeatJobName" strCommandLine = chr(34) & "C:\Program Files\Microsoft\SyncToy\SyncToy.exe" & chr(34) & " –R" & chr(34) & strJobName & chr(34) Set objWshShell = WScript.CreateObject("WScript.Shell") objWshShell.Exec(strCommandLine) According to the documentation there should be a space before the -r but none after the -r so that's what I did. Hope that helps.
  2. Hi Screweduphead (funny name by the way, I like it), If you haven't, you first need to go into the program and set up the folders you want to synchronize. After that you can name your job. The name of the job in the script should match the name that you gave the job in the SyncToy program. Once that has been done then it should work (or at least it does for me). I have never used SyncToy so for questions that are less scripty and more SyncToy-ish I'll leave you in the hands of others more knowledgeable than I.
  3. Hi Kyle, This was bugging me so I downloaded SyncToy and tried it out. Acrolite is correct, you do need the job name for it to run. strCommandLine = "C:\Program Files\Microsoft\SyncToy\SyncToy.exe –R MyFoldersTest" Set objWshShell = WScript.CreateObject("WScript.Shell") objWshShell.Exec(strCommandLine) The addition of the job name does the trick.
  4. Zabu

    Best script ever!

    So, I have hundreds of scripts, probably like most of you do too. Some are practical some are just for fun, some I made just for the challenge. What is your favorite script? It could be practical or it could be something that's just too cool/rad/whatever term is popular these days. To start with I'll post a fun script I made for my sister the other day. Her corporate office put out a memo that all of the Excel spreadsheets in the fiscal department needed to be in official corporate colors. I felt sorry for her and made a script that pulls up Excel files and changes the font color. I'm sorely tempted to use it here to change all of our spreadsheets on the file server to pink or something obnoxious. The second script I have actually used a couple of times. If you ever have to pull a printer off of the floor and replace it, this script can be run as a logon script that remaps the user to the new printer. That's a good start. I look forward to learning from you. Have a great day. printer_replacement.txt excel_worksheet_fontcolor.txt
  5. It depends on the environment. If you are in Active Directory then I would either put all of your teacher's computers in a particular OU or put the teacher computers in a group and filter a group policy so that it only affects computers in that security group. Or as Geoff suggested using filters on your GPOs works just as well. If you have questions about how to do that, let me know and I can score you some links. If you need to grab the computer name here it is: Set WshNetwork = WScript.CreateObject("WScript.Network") WScript.Echo "Computer Name: " & WshNetwork.ComputerName Happy hunting and have a great day.
  6. The easiest thing to do would be to use a .bat file (only one line needed). If, however, you are enamored with the sleek beauty of VB script (and who isn't?) then the following should work: strCommandLine = "C:\Program Files\Microsoft\SyncToy\SyncToy.exe –R" Set objWshShell = WScript.CreateObject("WScript.Shell") objWshShell.Exec(strCommandLine) If that does not work try replacing the first line with the following: strCommandLine = chr(34) & "C:\Program Files\Microsoft\SyncToy\SyncToy.exe" & chr(34) & " –R" Copy the lines into notepad and save it as something.vbs Let everyone know if that does not work or if you have questions. Have a great day.
  7. Here is a pretty flexible solution for running random files. It looks through a specified folder and picks a file at random out of the list of files in that folder. That way it works if you have 1 file in the folder or 100. dim arrImages(5000) strSourceFolder = "c:\FolderWithBatchFiles" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objWshShell = WScript.CreateObject("WScript.Shell") 'Get a list of all of the files in the folder set objFolder = objFSO.GetFolder(strSourceFolder) Set colBatchFolder = objFolder.Files For Each objBatchFile in colBatchFolder arrBatchFiles(i) = objBatchFile.Name i=i+1 Next ' Create a random number from 0 to i Randomize intRandomNumber = Int(rnd* i) 'Run that puppy WshShell.Run arrBatchFiles(intRandomNumber) A good check would be to look at the file extension before tossing it into the array to make sure that it was a .bat file. I originally made it to look through my pictures and toss a random one into the registry as my wallpaper, but ran into problems with XP not refreshing it. Because I converted it, the variable names are probably a little wonky. Another way would be a modification of what was posted above. Generate a random number from 1 to 5 and then use a case statement. Rather than going to an external file the case statement would call 1 of 5 subroutines that would run the part of the logon script that provides individualization. If needed, any common elements can be meted out to users either before or after that part runs. Have a great day.
  8. Hello, Debugging scripts within AD can be fun (with some liberties taken in the definition of "fun"). There are several things that you can do. One would be to combine both scripts into one. That way there is no worry about asynchronicity (unless the situation in option two is happening). Option two would be to use the DriveExists method on your second script. Sometimes it take a couple of bits for a drive to map or unmap (which could be why it sometimes works and sometimes does not). You could use the DriveExists method to wait until the drive does not exist (with a cutoff of a maximum number of seconds so you don't get stuck in a loop). You can look at this technet site for info about that method: http://msdn2.microsoft.com/en-us/library/t565x0f1.aspx Here is the code that I made for that: Set objFSO = CreateObject("Scripting.FileSystemObject") strDrivePath = "q" 'Use drive letter or UNC path (does not seem to be case sensitive) bolWait = True While bolWait = True WScript.Sleep 100 '1/10 of a second intCounter = intCounter + .1 If objFSO.DriveExists(strDrivePath) Then bolWait = False End If If intCounter >= 10 Then 'Waits for 10 seconds-adjust as needed bolWait = False End If Wend An another option, you could also have your two scripts write to a log file to see if they are indeed overlapping. Toss the following code into your scripts. const txtDebugLogFile = "c:\DebugLog.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objLogFile = objFSO.opentextfile(txtDebugLogFile,8,true) strStartTime = Time() ' 'Put the rest of your script here ' strEndTime = Time() objLogFile.writeline Wscript.ScriptFullName & "," & txtStartTime & "," & txtEndTime objLogFile.close There are probably more ways to look at this but hopefully this will help. Best of luck and feel free to respond with questions if needed.
×
×
  • Create New...