Jump to content

Scr1ptW1zard

Member
  • Posts

    67
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Everything posted by Scr1ptW1zard

  1. I would suggest you rethink your strategy on this. Your goal is to determine if ALL your servers can communicate with the KMS. This communication is performed over port 1688 (by default) and a ping request will not test for this. Take a look here http://technet.micro...y/ee939272.aspx for more troubleshooting information.
  2. crobertson, Are you looking to create a file containing the customer information contained in the variable (%destination%) and the list of installed applications? If so, perhaps this will work for you: @Echo off set destination=%date% - My Customer type nul>.\apps.txt type nul>.\sorted.txt for /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do ( echo "%%b"|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt ) sort .\apps.txt /o .\sorted.txt echo %destination%>.\destination.txt >nul copy .\destination.txt+.\sorted.txt .\backup.txt If this is not correct, please rephrase your question to explain exactly what you are looking for.
  3. I do not have a DOS system to test this on, only a Windows 7 command prompt (cmd.exe). This will do for the specific conditions you have listed. Changes will need to be made if any of the pet names will have spaces. @echo off Set Pets=Cats Dogs Horses Set Cats=FiFi FruFru Fluffy Set Dogs=Lassie MrMuggies RinTinTin Set Horses=MrEd Trigger For %%a In (%Pets%) Do ( For /f "Tokens=1,* delims== " %%b In ('set %%a') Do ( For %%n In (%%c) Do ( Echo %%a %%n ) ) )
  4. AceInfinity, Yzöwl is providing valuable feedback. Perhaps you meant to ask "How could this be done more efficiently?" In that case, here is some changes I would make: For the checking of command-line parameters, ask yourself "What do I need as input?" Your answer would be "at least 2 parameters". So, just check for that: if [%2] equ [] goto noArgs You can also do away with most of the variables. Set "original=%1" :start shift if [%1] equ [] goto :eof >>"bin_output\results.txt" fc /b %original% %1 goto start HTH
  5. Actually, to only list *.pdf files, you would need to modify the "dir" command line syntax that is listing the files. In the script, I have the following command line that is listing all files in a given directory: dir "%fldr%" /a-d /b What this is stating is "list all items in a bare, just display the file name, format (/b ) that are not directories (/a-d) in the specified directory (%fldr%)" To only show .pdf files, you would need to modify this command to the following: dir "%fldr%\*.pdf" /a-d /b To get a better understanding of what these command lines are doing, open a command prompt and run them from there, changing the %fldr% to a valid path. Something like this: dir "%userprofile%\documents\*.pdf" /a-d /b For a full list of command line switches for the 'dir' command, run dir /? at the command prompt. And if you want more information on what the "tokens=*" is, look at the help for the "for" command: ( for /? ) So, your new batch file would look like this: @echo off ::Change this variable to the directory containing the files Set "fldr=D:\Your Files Location" for /f "tokens=*" %%a in ('dir "%fldr%\*.pdf" /a-d /b') do md "%fldr%\%%~na"&move "%fldr%\%%a" "%fldr%\%%~na"
  6. This will create the folders in the same directory as the files you are working against. @echo off ::Change this variable to the directory containing the files Set "fldr=D:\Your Files Location" for /f "tokens=*" %%a in ('dir "%fldr%" /a-d /b') do md "%fldr%\%%~na"&move "%fldr%\%%a" "%fldr%\%%~na"
  7. Not sure if this is it, but try changing: <Group>Administrator</Group> to <Group>Administrators</Group>
  8. There are a couple a ways to do this: Option 1: Assuming the computer name is the label you are calling, as you wrote in your request. Change: if "%COMPUTERNAME%" == "Test" goto :TEST To: call :%COMPUTERNAME% goto :eof Option 2: Using the logic flow as you wrote it. Change: if "%COMPUTERNAME%" == "Test" goto :TEST To: if /i "%COMPUTERNAME%" == "Test" goto :TEST goto :eof Option 3: Exit the script when the condition does not match. Change: if "%COMPUTERNAME%" == "Test" goto :TEST To: if /i "%COMPUTERNAME%" NEQ "Test" goto :eof HTH
  9. Try this: If MsgBox( _ "Run New Process Notifier?",4132,"New Process Notifier") = 6 Then CreateObject("Wscript.Shell").Run("""C:\Program Files\New Process Notifier\NewProcessNotifier.exe"""),1,False End If Spaces in the path/file names require additional quotes.
  10. You did say you want to move all files up one level right? Here is how I would do that: @echo off ::Change the environment variable on the next line to the directory you want to move Set "movePath=D:\Temp\one" move "%movePath%" "%movePath%\..\.." This will move the folder "D:\Temp\one" and all sub folders and files to "D:\". So you will end up with "D:\one" and all sub directories.
  11. I believe this has to do with Novell's digital certificate. I have an unattended installation of this client working, although I am not using WPI. Prior to running your command to install the client, you will need to install the Novell certificate. I am using the following commands to accomplish this: certmgr.exe -add Novell.cer -c -s -r localMachine Root certmgr.exe -add Novell.cer -c -s -r localMachine TrustedPublisher You may have to specify the full paths for both certmgr.exe and Novell.cer, I placed both these files in my installation folder to make life easier.
  12. Based on your example, and the solution you had already found, try this: @echo off set /p var=text...<nul start /wait setup.exe ECHO Done!
  13. I use a .hta as my shell under WinPE also. You can add these lines: Set objWShell = CreateObject("WScript.Shell") objWShell.Run "cmd.exe %systemroot%\system32\diskpart.exe /s %systemroot%\system32\ospart.txt",0,True to your InstallOS.hta and set the shell (in winpesh.ini) like this: [LaunchApps] %SystemRoot%\System32\wpeinit.exe %SystemRoot%\System32\mshta.exe, %SystemRoot%\System32\InstallOS.hta
  14. Something like this? Batch file: @echo off :: batch code ::Prompt here cscript //nologo question.vbs if errorlevel 1 goto XY2 goto XY1 :XY1 echo You have chosen yes. goto :eof :XY2 echo You have chosen no. goto :eof VBScript file: Option Explicit Dim oShell, retCode Set oShell = WScript.CreateObject("WScript.Shell") retCode = oShell.Popup("Place your question here?", 30, "Title", 4 + 32) Select Case retCode case 6, -1 WScript.quit(0) 'Yes or time-out was chosen case 7 WScript.quit(1) 'No was chosen End Select This assumes both files are located in the same directory. Change the text you want displayed to the user. The vb script uses the quit method of wscript to provide an exit code that the batch file can use with an errorlevel check to determine what was chosen.
  15. "/wait" is not a valid switch for the copy command. You also have is elsewhere in your script as well as with the del command.
  16. I would go about this a different way, since you can not possibly account for every name that someone would enter. You have already been given a suggestion for using a "pick-list" for the users to choose from, mine will handle only the names that you provide a subroutine process to account for that particular name. I have also changed the variable from"hello" to "name" (makes things easier to follow). @echo off :top set /p %name%=Enter Name: echo Hello, %name% call :%name% 2>nul if errorlevel 1 ( echo Bad name goto top) goto :eof :: Provide a subroutine for each user name below :bob echo Running specific commands for Bob... goto :eof :john echo Running specific commands for John... goto :eof To carry this one step further, to retrieve the user's feeling: @echo off :top set /p name=Enter Name: echo Hello, %name% call :%name% 2>nul if errorlevel 1 ( echo Bad name goto top) :getfeeling set /p Feeling=How are you feeling %name% (Fine, Good, Great)? echo %name% is feeling %feeling%... call :_%feeling% 2>nul if errorlevel 1 ( echo Bad feeling... goto getfeeling) goto :eof :: Provide a subroutine for each user name below :bob echo Running specific commands for Bob... goto :eof :john echo Running specific commands for John... goto :eof :: Provide a subroutine for each user feeling below (start each with an underscore "_") :_fine echo Running commands for users that are feeling Fine... goto :eof :_good echo Running commands for users that are feeling Good... goto :eof :_great echo Running commands for users that are feeling Great... goto :eof I tried to keep it simple. You will still need to add the actions for each user and feeling. Also, it does not take into account if the user enters his/her full name. i.e. if the user enters Bob Smith, the script will still run for user Bob. HTH
  17. Fredledingue, I have several .hta's that I do this with. I have common script files that contain frequently used functions and subroutines. If I edit any of these common script files, my .hta's automatically have the update included. I find it very useful. Give it a try. Here is my actual include statements for one of my HTA's: <script Language=javascript src="./js/variables.js"></script> <script Language=javascript src="./js/functions.js"></script> <script language=javascript> window.onbeforeunload=preUnload; </script> <script Language=vbscript src="./vbs/objects.vbs"></script> <script Language=vbscript src="./vbs/constants.vbs"></script> <script Language=vbscript src="./vbs/subroutines.vbs"></script> <script Language=vbscript src="./vbs/functions.vbs"></script>
  18. Just include the file into your hta. Place this above any other <script> tags: <script Language=vbscript src="./yourfile.vbs"></script> yourfile.vbs will have these line contained within: Dim ProdID, AdminPassword ProdID = "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx" AdminPassword = "Password" That's it.
  19. I ran into this exact issue! Here is what I came up with to get around this: @echo off setlocal enabledelayedexpansion for /f "tokens=*" %%a in ('fsutil fsinfo drives^|more') do ( set drive=%%a set drive=!drive:Drives:=! set drive=!drive: =! echo !drive! fsutil fsinfo volumeinfo !drive!) endlocal
  20. Just checked the script submitted by Yzöwl on my systems, works fine (No reboot required). Please explain in more detail as to what is not working. Does the right-click menu have the "Open with ResHacker" item listed? Does the registry have the "Open with ResHacker" key under: "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\"? And the command subkey with the proper default value? Note: Your original registry file was using "HKEY_CLASSES_ROOT\*\shell\ResHacker"...
  21. There may be other ways to solve this, but this was my first thought: set D_Domain1=Server1 set D_Domain2=Server2 set D_Domain3=Server3 for /f "tokens=1,* delims==" %%a in ('set D_^|find /i "%USERDNSDOMAIN%"') do set Server=%%b net use O: \\%Server%\Share
  22. If you still need a batch script... Here is the modified version of my previous script that will take into account the "&" sign: @Echo Off type nul>.\apps.txt type nul>.\sorted.txt for /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do ( echo "%%b"|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt ) sort .\apps.txt /o .\sorted.txt But now the output will have quotation marks around every name. With some work, they can be removed also.
  23. Here's my quick thought on performing this task via batch: @Echo Off for /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do ( echo %%b|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt ) sort .\apps.txt /o .\sorted.txt You should be careful of what you filter out. I did not filter out "Microsoft" as you did in your post, since that would remove the Microsoft Office products.
  24. Here is a simple example: Batch.bat @echo off ::Batch.bat Echo Running batch.bat... echo Parameter #1: %1 echo Parameter #2: %2 echo Parameter #3: %3 call batch2.bat %1 %2 %3 echo batch.bat done! Batch2.bat: @echo off ::Batch2.bat Echo Running batch2.bat... echo Parameter #1: %1 echo Parameter #2: %2 echo Parameter #3: %3 echo batch2.bat done! Place both files in the same directory. Launch using the following command: Batch.bat one two three HTH
  25. For your first question, simply renaming the link should change the displayed name. This could easily be done with the rename command in a batch file, but here would be the vbscript way: Set fso = CreateObject("Scripting.FileSystemObject") Set WSHShell = WScript.CreateObject("WScript.Shell") StartMenu = WSHShell.SpecialFolders("StartMenu") OldLinkName="wupdmgr.exe.lnk" NewLinkName="New Name.lnk" if fso.fileexists(StartMenu + "\wupdmgr.exe.lnk") then set WUD=fso.GetFile(StartMenu + "\" + OldLinkName) WUD.Name=NewLinkName end if StartMenu=StartMenu + "\..\..\All Users\Start Menu" if fso.fileexists(StartMenu + "\wupdmgr.exe.lnk") then set WUD=fso.GetFile(StartMenu + "\" + OldLinkName) WUD.Name=NewLinkName end if Your second question would require a registry edit. Again, a batch file could perform this as well. Const HKLM = &H80000002 strUserName="UserNameHere" strPirctureSource="D:\Images\MyImageFile.jpg" Set objRegistry = GetObject("Winmgmts:root\default:StdRegProv") sKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Hints\" + strUserName objRegistry.CreateKey HKLM, sKeyPath lRC=objRegistry.SetStringValue(HKLM, sKeyPath, "PictureSource", strPirctureSource) Hope that helps!
×
×
  • Create New...