Jump to content

Modify_inc

Members
  • Posts

    9
  • Joined

  • Last visited

Modify_inc's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I have two .vbs files: test.vbs and scan.vbs. The two work fine when executed locally on a PC. It it when I try to execute them remotely via psexec that the scan.vbs gives me the following error on the remote PC: cscript.exe //Nologo "C:\Program Files (x86)\Common Files\Intuit\QuickBooks\scan.vbs" C:\Program Files (x86)\Common Files\Intuit\QuickBooks\scan.vbs(2, 1) (null): The system cannot find the file specified. I should note that I'm running a batch file that then executes the vbs file. Both batch files also work fine locally. Each batch file has only one command: batchscan.bat cscript //Nologo "C:\Program Files (x86)\Common Files\Intuit\QuickBooks\scan.vbs" batchtest.bat cscript //Nologo "C:\Program Files (x86)\Common Files\Intuit\QuickBooks\test.vbs" Here is the script for scan.vbs (Works only locally): Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run "QBServerUtilityMgr.exe" Wscript.Sleep 5000 objShell.AppActivate "QBServerUtilityMgr" objShell.SendKeys "{TAB}" objShell.SendKeys "{ENTER}" When ran remotely, line 2, objShell.Run "QBServerUtilityMgr.exe" is the line I assume it is complaining about and that it cannot find. The test.vbs runs without any errors, locally and remotely, so I'm curious what the difference is between the two files that would allow one to work both locally and remotely, while the other (scan.vbs) only appears to work locally? Here is the script for test.vbs (works both locally and remotely): Option Explicit Dim objFSO, objFSOText, objFolder, objFile Dim strDirectory, strFile strDirectory = "C:\VBScripts\" strFile = "\Summer.txt" ' Create the File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") ' Create the Folder specified by strDirectory on line 10 Set objFolder = objFSO.CreateFolder(strDirectory) ' -- The heart of the create file script '----------------------- 'Creates the file using the value of strFile on Line 11 ' ----------------------------------------------- Set objFile = objFSO.CreateTextFile(strDirectory & strFile) Wscript.Echo "Just created " & strDirectory & strFile Wscript.Quit
  2. Thank you, that worked!! I had forgot about the parseInt command.
  3. Thanks for the suggestion, but I would really like to know why the format I used did not perform the calculations as intended. To add to a variable, do you not type m=m+5 or m+=5. So that whatever is already assigned to the m variable, 5 is now added to it? So if originally, m=10, m would now equal 15. What am I doing wrong? This is all of my code: (I'm learning!)// Declare variables and constantsvar cat; // categoryvar cards ; // # of cards per categoryvar type; // temp value for category typevar m = 0; // morning variablevar n = 0; // noon variablevar e = 0; // evening variablevar final; // temp variable to calculate all totalsvar BR = "<br />"; // HTML line breakvar ES = ""; // literal empty stringwhile (type != 4) { // Reinitalize variables cat = "a";cards = "a"; // Welcome the user document.write("Welcome to Mack's Coffee Cove!"+ BR); // Check input while (cat != "morning" && cat != "noon" && cat != "evening" && cat != "t") { cat = prompt("Enter the card Category (morning, noon, evening), Press t to total all 3 categories: ",ES); } // Determine type if (cat == "morning") { type = 1; } else if (cat == "noon") { type = 2; } else if (cat == "evening") { type = 3; } else { type = 4 } if (cat != "t") { // Check input while (isNaN(cards)) { cards = prompt("Enter the number of cards collected for the " + cat + " batch: ",ES); if (type == 1) { m += cards; document.write("You entered " + cards + " survey cards for the morning." + BR); } else if (type == 2) { n += cards; document.write("You entered " + cards + " survey cards for noon." + BR); } else if (type == 3) { e += cards; document.write("You entered " + cards + " survey cards for the evening." + BR); } } }}// Sum and display totals for all categoriesfinal = m + n + e;document.write("Totals for all categories: " + final + BR);document.write("Morning total: " + m + " Noon Total: " + n + " Evening Total: " + e + BR);// Thank the clientdocument.write("Thank you!" + BR);
  4. Can you tell me why this line works, but then why does it put undefined before the answer though?It's like it's trying to concatenate the variable instead of just displaying the stored value for the variable.I say that because I initialized the m variable to zero, and it displayed the Morning total as 015 (appending the zero to the total)if it helps, I am using m += cards to achieve this. Also tried m = m + cards with same results.document.write("Morning total: " + m + " Noon Total: " + n + " Evening Total: " + e);Thanks againMike
  5. k, got it thanks. Can you tell me why this line works, but then why does it put undefined before the answer though?It's like it's trying to concatenate the variable instead of just displaying the stored value for the variable(s).I say that because I initialized the m variable to 0, and it displayed Morning total: 015 (appending the zero to the total) if it helps, I am using m += cards to achieve this. Also tried m = m + cards with same results. document.write("Morning total: " + m + " Noon Total: " + n + " Evening Total: " + e + BR); Thanks againMike
  6. now why does this one exit while the condition is still true? I even initialized the variable with a letter with the same results. I also tried swapping the operator just in case I had it reversed as I did previously, but it then loops continually whether I type a character or a number. while (cards == NaN) { cards = prompt("Enter the number of cards collected for the " + cat + " batch: ",ES);}
  7. that was it, thank you very much!
  8. Can someoe please tell me what is wrong with this while statement? It will execute, but it continues even if the condition is false (which is suppose to exit the loop). I do not understand why it will not exit the loop. document.write("Welcome to Mack's Coffee Cove!"+ BR); while (cat != "morning" || cat != "noon" || cat != "evening") { cat = prompt("Enter the card category (morning, noon, evening): ",ES); } I've also tried it with 'do' at the begining and the 'while' statment at the end with same results. Is it something to do with my conditon? Mike
  9. I'm trying to understand why my username validation code is not working correctly. For the most part it works, but if you enter the username format wrong two or three times, the browser locks up and requires a forced restart of the browser. I'm a newbie at JavaScript, so keep that in mind when looking at my code. I assume it's related to a while or if statement, although I'm not experienced enough to figure it out at this point. If I enter a username with less than 8 characters, it prompts me that I must have at least 8. If I enter 8 characters with a number for the first character, it prompts me that the first character must be a letter. If then I enter all characters for the username, the browser crashes. (During this time, it should be checking that at least one digit was used) < html > < body > < script type = "text/javascript" >// Declare variablesvar username; // potential username entered by uservar anyDigits = false; // variable to signify presence of digitsvar index; // loop variable for extracting charactersvar BR = "<br />";var ES = "";// Display program heading and requirements and ask for usernamedocument.write("This program helps you set up a valid username." + BR);document.write("Your username must be at least 8 characters long," + BR);document.write(" start with a letter, and contain at least 1 digit." + BR);username = prompt("Please enter your name: ", ES);// Check for length of usernamewhile (username.length < 8 ) { document.write("ERROR...your username must be at least 8 characters long." + BR); username = prompt("Please enter your new username: ", ES);}// Check that first character is a letter// Substring function has three arguments: string, starting position, and ending positionchar1 = username.substr(0, 1);while (!(isNaN(char1))) { document.write("ERROR: the first character of your username must be a letter." + BR); username = prompt("Please enter your new username: ", ES); char1 = username.substr(0, 1);}// Check that there's at least one digit in the usernamewhile (anyDigits !== true) { // Check each character, set anyDigits to true if a digit for (index = 0; index < username.length; index++) { char1 = username.substr(index, 1); if (!(isNaN(parseInt(char1)))) { anyDigits = true; } } // If anyDigits is still false, no digits were present if (anyDigits !== true) { document.write("ERROR:...your username must include at least 1 digit." + BR); //username = prompt("Please enter your new username: ", ES); }}// Thank the user and end the programdocument.write("Thank you! Your new username is: " + username);< /script></body > < /html> Thanks Mike
×
×
  • Create New...