Web Images News Groups Scholar Blogs Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Script
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
PaulM  
View profile  
 More options Nov 5, 10:54 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "PaulM" <N...@NONO.COM>
Date: Thu, 5 Nov 2009 17:54:44 -0500
Local: Thurs, Nov 5 2009 10:54 pm
Subject: Script
Why does this script work:

' Description: Demonstration script that uses the FileSystemObject to delete
a file. Local computer
' For Vista

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFile("F:\Users\TestUser\AppData\Local\test.vbs")

And this script does not work:

' Description: Demonstration script that uses the FileSystemObject to delete
a file. Local computer
' For Vista

Dim Windir
Dim Users
Dim UserProfile
Dim AppData
Dim Local

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Windir = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
Users =  WshShell.ExpandEnvironmentStrings("%Users%")
UserProfile = WshShell.ExpandEnvironmentStrings("%UserProfile%")
AppData = WshShell.ExpandEnvironmentStrings("%AppData%")
Local = WshShell.ExpandEnvironmentStrings("%Local%")

objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs")


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 5, 11:10 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 00:10:52 +0100
Local: Thurs, Nov 5 2009 11:10 pm
Subject: Re: Script

"PaulM" <N...@NONO.COM> wrote in message

news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...

If you replace the line
objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs")
with this line
wscript.echo "%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\test.vbs"
then you will see immediately why it cannot possibly work. Neither
objFSO.DeleteFile nor wscript.echo can resolve environmental variables such
as %SystemRoot%. How about something like this?

objFSO.DeleteFile(Local & "\test.vbs")

I also urge you to open a Command Prompt (click Start / Run / cmd {OK} and
type this command:

echo %SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%

I took it right from your own code. As you see, it produces nonsense.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Mueller [MVP]  
View profile  
 More options Nov 5, 11:20 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net>
Date: Thu, 5 Nov 2009 17:20:01 -0600
Local: Thurs, Nov 5 2009 11:20 pm
Subject: Re: Script

"PaulM" <N...@NONO.COM> wrote in message

news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...

Check out the LocalAppData environment variable. Also, once you retrieve the
value of the environment variable and assign it to a variable, use the
variable. For example, try:
========
Dim LocalAppData, WshShell, objFSO

Set WshShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

LocalAppData = WshShell.ExpandEnvironmentStrings("%LocalAppData%")

objFSO.DeleteFile(LocalAppData & "\test.vbs")
=========
You can troubleshoot with statements similar to:

  Wscript.Echo LocalAppData & "\test.vbs"

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
PaulM  
View profile  
 More options Nov 6, 9:08 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "PaulM" <N...@NONO.COM>
Date: Fri, 6 Nov 2009 16:08:28 -0500
Local: Fri, Nov 6 2009 9:08 pm
Subject: Re: Script
Thanks

"Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net> wrote in
message news:OreMP6mXKHA.412@TK2MSFTNGP04.phx.gbl...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google