- Posts: 1302
- Thank you received: 0
Batch File/Script
16 years 11 months ago #24221
by DaLight
Replied by DaLight on topic Re: Batch File/Script
Windows Powershell will do the job (as long as your clients use Windows XP and upwards). Incredibly powerful scripting language.
- skepticals
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 783
- Thank you received: 0
16 years 11 months ago #24223
by skepticals
Replied by skepticals on topic Re: Batch File/Script
Here is the problem:
The file I will replace will execute each time I close Internet Explorer OR Log off the program.
I was thinking that I could program the new file to not do anything if it knows it was executed after closing IE.
Does anyone know a handy way of detecting when a program was execuded?
The file I will replace will execute each time I close Internet Explorer OR Log off the program.
I was thinking that I could program the new file to not do anything if it knows it was executed after closing IE.
Does anyone know a handy way of detecting when a program was execuded?
16 years 11 months ago #24226
by jtartist
Replied by jtartist on topic Re: Batch File/Script
Windows has a performance monitor and alerts snap in. I know you can setup alerts with the option of executing a specified program if a specified process starts, not sure if it lets you set it up the other way around though, but worth looking into.
16 years 11 months ago #24251
by ZiPPy
Based on your inquiry I came up with the following. Now I'm not a programmer, but I spoke with one of my IS buddies at work and he coded something real quick in Perl. Basically, you just need to input the process name to be called. Hopefully this helps or gives you a better idea. I work in the IT department and feel that I should learn Perl. Perl can really be a really good friend to any IT guy.
use Win32::Process::Info;
# Get the process name from the input arguments
$processName = shift;
# Create a new instance of the process info module
$pi = Win32::Process::Info->new();
# Get all available process info
@info = $pi->GetProcInfo();
# If we received a process name, let's look for it
if($processName)
{
# For every process in the list, look for the one we want
foreach $item (@info)
{
$name = "$item->{'Name'}";
if($name =~ m/$processName/i)
{
# We found the process!
print "Found process $name\n";
# Here's where something special happens
}
}
}
# No process name was given, so just produce a list of running processes
else
{
foreach $item (@info)
{
$name = "$item->{'Name'}";
print "$name\n";
}
}
system("pause");
ZiPPy
ZiPPy
Replied by ZiPPy on topic Re: Batch File/Script
We have a software application that calls a file "Remove.exe" when a user closes Internet Explorer AND when they log off the system (They are not logging off of Windows - just logging off a program.)
I replaced Remove.exe with my own modified file, but I only want the file to execute when someone logs off the system NOT when someone closes Internet Explorer.
Is there a way is some type of batch file or scripting language that I can have the system check if a processes is running? My thought is that when a user logs off there will be at least one less process; so in the batch file I can say somehting like, if this process is running do nothing and if the process is not running do this.
Based on your inquiry I came up with the following. Now I'm not a programmer, but I spoke with one of my IS buddies at work and he coded something real quick in Perl. Basically, you just need to input the process name to be called. Hopefully this helps or gives you a better idea. I work in the IT department and feel that I should learn Perl. Perl can really be a really good friend to any IT guy.
use Win32::Process::Info;
# Get the process name from the input arguments
$processName = shift;
# Create a new instance of the process info module
$pi = Win32::Process::Info->new();
# Get all available process info
@info = $pi->GetProcInfo();
# If we received a process name, let's look for it
if($processName)
{
# For every process in the list, look for the one we want
foreach $item (@info)
{
$name = "$item->{'Name'}";
if($name =~ m/$processName/i)
{
# We found the process!
print "Found process $name\n";
# Here's where something special happens
}
}
}
# No process name was given, so just produce a list of running processes
else
{
foreach $item (@info)
{
$name = "$item->{'Name'}";
print "$name\n";
}
}
system("pause");
ZiPPy
ZiPPy
- skepticals
- Topic Author
- Offline
- Elite Member
Less
More
- Posts: 783
- Thank you received: 0
16 years 11 months ago #24265
by skepticals
Replied by skepticals on topic Re: Batch File/Script
Zippy,
Thanks for the reply. I ended up using a batch file and and a program that can convert batch files into and EXE.
THe way I used to get the processes running was by using the "tasklist" command. I used tasklist and piped | it to the find command. The find command searches for the process I needed and returned one of two error levels. One if it finds the process and one if it does not. This seems to be working.
I will take a look at the perl.
Thanks!
Thanks for the reply. I ended up using a batch file and and a program that can convert batch files into and EXE.
THe way I used to get the processes running was by using the "tasklist" command. I used tasklist and piped | it to the find command. The find command searches for the process I needed and returned one of two error levels. One if it finds the process and one if it does not. This seems to be working.
I will take a look at the perl.
Thanks!
16 years 11 months ago #24269
by ZiPPy
ZiPPy
Replied by ZiPPy on topic Re: Batch File/Script
I think creating a simple batch file would be the quickest way to go. The Perl script can get down to the nitty gritty of what you want, but of course this takes more coding.
What made you want to create this? I think its pretty cool to go beyond the lines here to create a function. One that you made on your own. I haven't touched batch files in such a long time. I remember when I use to make simple batch files to share a drive or remove them ect... hehe.
ZiPPy
What made you want to create this? I think its pretty cool to go beyond the lines here to create a function. One that you made on your own. I haven't touched batch files in such a long time. I remember when I use to make simple batch files to share a drive or remove them ect... hehe.
ZiPPy
ZiPPy
Time to create page: 0.133 seconds