I need to auto switch between 2 windows which are dashboards from the same program, but run in seperate windows. I saw the following:
Option Explicit
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WScript.Sleep 30000
WshShell.SendKeys("%{TAB}")
Loop
There is a note: If you want to stop it, then you need to kill the process called "wscript".
Can someone tell me how to include this kill command, as when i run the code i get stuck in an endless loop and need to restart pc to stop it.
Perhaps there is a better solution even? its for an office tv that needs to rotate between dashboards of data on seperate windows.
Thanks!
Related
I have a supervision tool that can deploy scripts on customers end devices.
I'm trying to make two powershell scripts.
The first one is supposed to launch a "chkdsk disk_name: /f /r".
The second one is supposed to extract the result of the chkdsk after the reboot from the event viewer.
The second script is operational. My problem is with the first one.
I think that when I'm launching my job from my administration tool, the script is launched on the end device, but when you type "chkdsk disk_name: /f /r" on a command prompt, it asks if you want to do the chkdsk at the start of the machine because the disk is actually in use. I think that the letter "Y" that you have to type to confirm, is blocking the execution of the command (and my script by consequence).
I didn't find in the documentation of the command any method to launch it with a "default confirmation".
Do you have any idea of what I can do to automate this?
Sorry for my English, it's not my native language.
Thank you all!
I tried to launch the script (it's in admin mode when my administration tool launch it's job) but the result was that my job was running indefinitely and at the restart of the machine, the check disk is not performed.
The problem I am having is that any powershell script that I try to run, either by double clicking or using "powershell /path/to/script" from cmd, will open a window, then close, then open another window, then close, and so on... The code never actually runs though.
I have set the execution policy to what it needs to be to allow powershell scripts to run. I have tried running as administrator. I have tried this on 2 separate computers running Windows 10. I've tried using these 3 scripts as test scripts with the same result:
1
write-host("hello")
2
write-host("hello")
cmd /c pause
3
cmd /c pause
Has anyone seen this behavior and know how to fix it?
I have been running a program using nohup but I forgot to add & after the command so the terminal is stuck on the process that has been running for hours. the script I am running in python generates 5 processes each time.
Is there anyway I can make the entire script to continue in the background (get the same effect as an &) without killing and rerunning the process.
Hit Ctrl-Z to suspend the process.
Then bg to tell it to run again as a background process.
I have script to uninstall a package say pkg_1 using it's uninstallstring (i.e. setup.exe -remove). After that it is trying to remove another package say pkg_2. The uninstallation of pkg_1 takes around 1 to 2 minutes. the script looks like as below
rc = shellobj.Run("cmd /C " & uninstall_string_1 & " /silent",0, true)
rc1 = shellobj.Run("cmd /C " & uninstall_string_2 & " /silent",0, true)
Here what's my problem is, if you place WScript.sleep(120000) between above two statements, both packages are getting removed successfully. Otherwise, uninstaaltion of pkg_1 is halted and uninstallation of pkg_2 begins immediately. As a result only pkg_2 is getting removed(without sleep).
How can i do the uninstallation of two packages without using sleep method?
FYI
If you run uninstall_string_1 from command prompt, new prompt will be opned after 0-5 seconds and uninstallation proceeds in background
Arjun, I read this in another forum :
When we use scripts to install or uninstall packages, it depends very much on the implementation of the package. Let's say setup.exe itself run as process A. Process A does some nominal verification then spawns a process B, the real installation engine, then close itself out. In this case, the bWaitOnReturn(which you have set to true in your code) has done its work and the control will hand to the next statement. However, the process B is still running. That is out of the control of the bWaitOnReturn. So your 2nd package will start before your 1rst package is actually completed. Maybe your 1rst package is not actually halted, it might be taking time and executing in the background. Thats just a guess anyways.
If that is not the case, can you also try this :
Set obj0 = CreateObject("WScript.Shell")
Set objExec = obj0.Exec("your package../../")
' We will set a loop until finished
Do While objExec.Status <> 1
WScript.Sleep 100
Loop
So every 100ms, script will check if your package has completed execution. And if it has, it will move to next statement.
Try this one:
strCmd = uninstall_string_1 & " & " & uninstall_string_2
rc = shellObj.Run("cmd /C " & strCmd, 0, True)
I'm trying to display messages as my vbscript program runs. It runs off a command prompt in xp, for example: cscript.exe test.vbs. I don't want to use msgBox while this is running as I just want it to post the scripts progress, but I don't want any user interaction.
I tried using Wscript.echo "Some text", but I'm getting compile errors when I step through the program using Words built-in vbeditor.
I found this code and it runs fine in another file:
Option Explicit
Dim strComputer
strComputer = "LocalHost"
WScript.Echo "Computer: " _
& strComputer
WScript.Quit
I then tried using Dim and set to setup a Wscript variable, but that didn't work either.
Any ideas as to what I'm doing wrong? I did verify Wscript is running on this machine.
Thanks,
James
Word uses VBA (Visual Basic for Applications), not VBScript. Although both languages belong to the Visual Basic family, they have differences. One of them is that the WScript object isn't available in VBA - that's why you're getting errors when debugging your script in Word.
Having said that, your code is valid and runs perfectly fine with both cscript and wscript.